Ruby/Reflection/FILE

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

(Различия между версиями)
Перейти к: навигация, поиск

Версия 17:10, 26 мая 2010

The keyword __FILE__ stands for the name of the file containing the code.

puts __FILE__
class MyClass
  @@note = "A"
  def sing_hello
    @@note.succ!.succ!
    print "Hello... ", @@note, " "
  end
 end
myObject = [MyClass.new, MyClass.new, MyClass.new]
myObject.each { |stooge| stooge.sing_hello }