Some random things that the author seem to have missed: > but TypeScript, Swift, Kotlin, and Scala take string interpolation to the furthest extreme of encouraging actual code being embedded inside strings Many more languages support that: C# $"{x} plus {y} equals {x + y}" Python f"{x} plus {y} equals {x + y}" JavaScript `${x} plus ${y} equals ${x + y}` Ruby "#{x} plus #{y} equals #{x + y}" Shell "$x plus $y equals $…
Ruby takes this to 100. As much as a I love Ruby, this is valid Ruby, and I can't defend this: puts "This is #{ Just to combine the string interpolation with her concern over Ruby heredocs. My other favorite evil quirk in Ruby is that whitespace is a valid quote character in Ruby. The string (without the quotes) "% hello " is a quoted string containing "hello" (without the quotes), as "%" in contexts where there is n…
puts "hello #{
yields hello recursion is recursive world
that was fun
and then there's its backtick friend puts "hello #{
coughs up hello Sun Nov 3 17:25:32 UTC 2024 world
and for those trying out your percent-space trick, be aware that it only tolerates such a thing in a standalone expression context so puts (% hello )+" world"
# or
x = % hello #
puts x
because when I tried it "normally" I got $ /usr/bin/ruby -e 'puts % hello + "world"'
-e:1:in `': undefined local variable or method `hello' for main:Object (NameError)
$ /usr/bin/ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin21]
but, at the intersection is "ruby parsing is the 15th circle of hell" ruby -e 'puts (% #{