"class <




"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 category

1.Use singleton_method_added to call a singleton method
2.Add method to an instance