3 ms·
Like PHP and JS's template literals, it has full on string interpolation.
by goatlover 10y ago
Like PHP and JS's template literals, it has full on string interpolation.
- anamoulous 10y agoArguably Ruby is worse because you can execute instance methods in interpolation, but I still don't see why that's germane to this discussion other than to pick a fight about languages.
- smitherfield 10y agoRuby string interpolation can only happen in literal source code, not in user input. 2.4.0 :001 > a = 5 => 5 2.4.0 :002 > gets.chomp #{a} => "\#{a}"
- Manishearth 10y agoThese are only in literals, however. You cannot have a string value with interpolation exprs inside it (both in JS and Ruby)
- jsjohnst 10y agoGuys, this has nothing to do with interpolation. I like both Python and Ruby's string interpolation. I'm replying to the incredulous parent of my post who's griping about magic methods (which admittedly Ruby likely takes the crown).