Ruby on Rails Friday, December 21, 2012

Nirav Bhatu wrote in post #1089902:
> I am shocked that we can change the value of constant in ruby!!
>

What about this:

class Dog
def initialize(password)
@secret = password
end
end

d = Dog.new("flower52")
puts d.instance_eval("@secret")

--output:--
flower52

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment