Suppose the following code:
=20
t=3D'#{a} + #{b}'
...
a=3D'a';b=3D'b'
=20
How to cause ruby to interpret t as a "string" to get the result = string
"a + b"?
Well, instead of using the string interpolation syntax, you can use
String#%
which interpolates a String at runtime.
In Ruby 1.8.7 without additions, you can use it link this:
"My string contains a %s and a number as string: %s" % ["string", 123]
You can also format that stuff, etc.
In Ruby 1.9.2 and 1.8.7 with certain additions (for example i18n), you =
can use it like this:
"My String contrains a %{string} and a number as string: %{integer}" % =
{:string =3D> "string", :integer =3D> 123}
This allows you to define that string somewhere else and fill it in =
later on.
Regards,
Florian
--
Florian Gilcher
smtp: (e-mail address removed)
jabber: (e-mail address removed)
gpg: 533148E2