After I thought the variable scope would be the reason I got the hint, that substitution depends on if the first character of a variable is a letter/underscore or not. But I don't understand the intention. Let's take this example:
$var1 = "bar"
_var2 = "bar"
var3 = "bar"
Var4 = "bar"
@var5 = "bar"
puts "foo #$var1"
puts "foo #_var2"
puts "foo #var3"
puts "foo #Var4"
puts "foo #@var5"
which results in this:
foo bar
foo #_var2
foo #var3
foo #Var4
foo bar
I would expect for all 5 lines the same. Is it a bug? Or what's the intention of this behaviour?