3 ms·
You can do this in Ruby too, with sprintf. It's almost as if there are multiple, complimentary ways of accomplishing similar tasks, depending on your needs.
by stouset 12y ago
You can do this in Ruby too, with sprintf. It's almost as if there are multiple, complimentary ways of accomplishing similar tasks, depending on your needs.
- moe 12y agoYou don't even need sprintf, Ruby supports Python-style interpolation, too: bar='batz' "foo #{bar} #{0.5+0.5}" => "foo batz 1.0" "foo %s %.2f" % [bar, 1.0] => "foo batz 1.00"
- stouset 12y ago% is an alias for sprintf. :)
- dragonwriter 12y agoYeah, I was comparing the Python and Ruby features already under discussion in the thread, not what is available in each language, but that's useful to point out given that people might not be aware of it.