From: Florian Gilcher Date: 2010-12-07T22:41:56+09:00 Subject: Re: How to delay "string" interpretation? On Dec 7, 2010, at 1:11 PM, Fritz Trapper wrote: > Suppose the following code: > > t='#{a} + #{b}' > ... > a='a';b='b' > > 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 => "string", :integer => 123} This allows you to define that string somewhere else and fill it in later on. Regards, Florian -- Florian Gilcher smtp: flo@andersground.net jabber: Skade@jabber.ccc.de gpg: 533148E2