"self" is a reference to the current object instance.here is an example:
class Leaf
def print_self
p self
end
def to_s
"I am a leaf"
end
end
l = Leaf.new
l.to_s
=> "I am a leaf"
l.print_self
=> I am a leaf
"self" is a reference to the current object instance.here is an example:
class Leaf
def print_self
p self
end
def to_s
"I am a leaf"
end
end
l = Leaf.new
l.to_s
=> "I am a leaf"
l.print_self
=> I am a leaf