Navindra Umanee wrote: > > the String is evaluated? I can think of some hacky ways i.e. doing > > subsequent string processing and substitions, I'm just wondering if > > there is a more elegant way. > > To add to that, I thought about leaving a few "%s" in the string and > replacing them later, but that too seems ugly because I have feed in > variables in order and sometimes even repeatedly. > You could write your interpolater. Here is an example: $ irb irb(main):001:0> require 'tmp.rb' => true irb(main):002:0> s = ":hey :day" => ":hey :day" irb(main):003:0> s.interpolate(:hey => "hello", :day=>"yo") => "hello yo" $ cat tmp.rb class String def interpolate(hash) self.gsub(/:(\w+)/) { hash[$1.to_sym] } end def interpolate!(hash) self.gsub!(/:(\w+)/) { hash[$1.to_sym] } end end $ -Charlie