To see who is playing the role of `self` in `nested methods`, I tried
the below code:
def test
p "#{self}"
def show
p "#{self}"
end
end
# => nil
As an effect, I got the two objects below:
Object.new.test
"#<Object:0x00000002212d78>"
# => nil
Object.new.test.show
"#<Object:0x00000002205330>" #<~~~ this is self understood
"" #<~~~ how this one came?
# => ""
But from the encoded numbers, I couldn't understand which class those
objects belong to. And I tried the code below and got the respective
`class` names.
Object.new.test.class
"#<Object:0x000000021ff3b8>"
# => NilClass
Object.new.test.show.class
"#<Object:0x000000020660b0>"
""
# => String
So can anyone help me to understand the concept of how the above code
produced those `class` names?
···
--
Posted via http://www.ruby-forum.com/.