Are Ruby formatted strings and interpolated strings identical in behaviour?
Posted
by Steve Weet
on Stack Overflow
See other posts from Stack Overflow
or by Steve Weet
Published on 2010-04-28T12:56:17Z
Indexed on
2010/04/28
13:33 UTC
Read the original article
Hit count: 174
ruby
|ruby-on-rails
Do the following two lines of code behave in exactly the same way despite slightly different implementations
values.map{ |k,v| __send__('%s=' % k.to_s, v) }
values.map{ |k,v| __send__("#{k.to_s}=", v) }
The second line would be a more common ruby idiom so I was wondering why the other method was used when this was in the Rails Core which I would expect to use idiomatic ruby.
© Stack Overflow or respective owner