From: Ryan Ingram Date: 2008-01-30T07:16:35+09:00 Subject: Re: what's the diff between puts y and puts "#{y}" in class_ Yep, you've got it exactly. On 1/28/08, 7stud -- wrote: > Thanks for the explanation, I've been watching this thread and waiting > for an explanation that I could comprehend. If I understand your > explanation correctly, the steps are: > > 1) The substitution in the string: > > str =< def hello > puts #{y} > end > STR > > is performed. The scope is the global scope, so the string becomes: > > str =< def hello > puts first > end > STR > > 2) The string is class_eval'ed in the scope of class T, producing: > > class T > def first > "hello" > end > > def second > "chunky bacon" > end > > def hello > puts first > end > end > > 3) When the method hello is called, the line: > > puts first > > outputs the return value of the first method.