------art_48402_1274274.1179501923606
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

hello Guys,

let me give another example. let say you want to create a greeting base on a
person name. You will write:

def greetings(name)
  "Good Morning #{name.capitalize}"
end

puts greetings('loi')
"Good Morning Loi"

as you can see the #{} allows you to create complex expressions. In this
case you were able to capitilize the name Loi even though you entered it in
lower case letter. So when the interpreter does the interpolation sees the
method capitalize and capitalize the name for you.

I hope this example will help you

Carlos Henriquez

On 5/18/07, Sebastian Hungerecker <sepp2k / googlemail.com> wrote:
>
> jim o wrote:
> > What does the "#{ }" do for you? I think what I am missing is the
> feature
> > provided by having that as a wrapper vs bare.
>
> You can't use bare variables inside a string.
> xp> puts "The number is x"
>
> This will return (of course) print out "The number is x" because ruby has
> no way of knowing that you actually wanted it to print out the value of
> the variable x instead of a literal x. If you however put #{} around the
> x,
> it will be substituted with the value of x.
> That's the point of the #{}. There's however no point to pass a string to
> puts
> that only contains a #{} because than you could as well just pass the
> variable
> to puts.
>
>
> --
> Ist so, weil ist so
> Bleibt so, weil war so
>
>

------art_48402_1274274.1179501923606--