Looking at this instance_eval example:
class KlassWithSecret
def initialize
@secret = 99
end
def get
@secret
end
end
k = KlassWithSecret.new
k.instance_eval { @secret }
print k.get
I added a get method to KlassWithSecret.
Here's the results of running the program:
>ruby InstanceEvalTest.rb
99
So, does instance_eval here somehow call the initialize method?
I think that I understand this method a bit from reading this helpful post. But I'm still in the dark.