Ruby/Class/Object in Ruby

Материал из Wiki.crossplatform.ru

Версия от 17:55, 13 сентября 2010; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Содержание

abs absolute value method

puts -1.abs



All strings in Ruby are objects of the String class, as you can discover by calling a string"s class method

puts "Hello, world!".class



Everything is an object or object-oriented in Ruby.

# the expression 1.+ is simply calling the + method of the 1 object
puts 1.+(2)



Get the modules Object class belongs to

p Object.included_modules # => [Kernel]