"class < a = "hello" b = a.dup class <<a def to_s "The value is '#{self}'" end def twoTimes self + self end end a.to_s a.twoTimes b.to_s Related examples in the same category1.Use singleton_method_added to call a singleton method2.Add method to an instance
a = "hello" b = a.dup class <<a def to_s "The value is '#{self}'" end def twoTimes self + self end end a.to_s a.twoTimes b.to_s