=> Object ! def self.my_method :my_method end ! p self.my_method #=> :my_method # 2.1.0 new feature m = def my_method :my_method end ! p send(m) #=> :my_method p self # => main p self.class # => Object ! def my_method :my_method end ! p my_method #=> :my_method
end def my_metho2 :my_metho2 end end obj1 = Foo.new p obj1.my_method #=> :my_method ! obj2 = Foo.new p obj2.my_method #=> :my_method p obj2.my_metho2 #=> :my_metho2
def my_metho2 :my_metho2 end def self.my_class_method :my_class_method end end p Foo.my_class_method #=> :my_class_method obj1 = MyClass.new p obj1.my_method #=> :my_method p obj1.my_metho2 #=> :my_metho2
class Foo def goodbye puts "goodbye" end end class Foo def hello(name) puts "hello #{name} san" end end Foo.new.hello 'rubico' => "hello rubico san" Foo.new.goodbye => 'goodbye'
module Goodbye def goodbye puts "goodbye" end end class Foo include Goodbye end ! Foo.new.hello name:'rubico' => "hello rubico" Foo.new.goodbye => 'goodbye'