How to do this



I don't know how to explain so I will just code:

template = 'some text #{variable}' # single quotes for reason
variable = 'filled'
res = some_method(template)

Here, res should have value 'some text filled'.

Is there an easy way doing this in ruby. Hard way is of course parsing
and inserting text with my own method.

by
TheR

--
Posted via http://www.ruby-forum.com/.

.



Relevant Pages

  • Ruby doesnt work correctly
    ... Im a beginner in Ruby, but with skills in other programming languages. ... require 'uri' ... I got the code from http://www.ruby-doc.org/stdlib/ -> net/http. ... Line 5 is: res = ...
    (comp.lang.ruby)
  • Re: Collect objects from an array based on one unique parame
    ... A slight change of my previously posted code may make it clearer. ... res << item ... RAILS ROUTING (new! ... RUBY FOR RAILS ...
    (comp.lang.ruby)
  • Re: [Q] removing array duplicates where a subset is unique
    ... I think what Joel was referring to was that in Ruby 1.8 a Hash doesn't ... maintain insertion order when traversed (Ruby 1.9 does maintain ... res = ...
    (comp.lang.ruby)
  • Re: embedding ruby
    ... are global variables and also because of the stack. ... can I assume that it is safe to use the ruby engine ... int res = 0; ...
    (comp.lang.ruby)
  • Re: Splitting string into array keeping delimiters
    ... Now I want to separate the digit group with the non-digit group into an ... How can I do it in Ruby with the least lines of code possible? ... res << $2.to_i if $2 ...
    (comp.lang.ruby)