From: Ryan Ingram Date: 2008-01-29T11:20:13+09:00 Subject: Re: what's the diff between puts y and puts "#{y}" in class_ On 1/28/08, Raj Singh wrote: > Could you please further elaborate on that. To me it seems like both of > them have the same scope because they are both being used in the same > method. Compare to this: class T def first "hello" end def second "chunky bacon" end end y = "first" T.class_eval <<-END def hello puts #{y} end END T.new.hello # prints "hello" The key is that the "<<-END" is creating an interpolated string in the original context; the interpolation of #{y} isn't happening during the call to "hello", but rather as part of the string passed to class_eval. You are probably confused by the fact that in the sample code, the interpolation is happening inside of another string constant, which makes it look like it's happening as part of "hello". It's not. -- ryan