singleton_method means object’s specific method
when we define method on specific object, will insert the singleton class between object and his class.
- puts example2. class
- class << example2
- puts self
- end
輸出結果:
- ExampleClass
- #<Class:#<ExampleClass:0x28305d>>
And if we add class method on class just like add singleton method on class
沒有留言:
張貼留言