Closed Guevara-chan closed 6 years ago
This should work. You're seeing a parser error, which happens well before any interpretation of string interpolations, and one that doesn't reproduce on my end, so I'm not quite sure what's going on with your code.
Cool. That being said, enclosing interpolated string with brackets works for some reason:
("hello, $name !").cap()
# No error here.
Right. If it's a simple reference expression, no parens or brackets are needed. They're only needed if you're enclosing more than one identifier, like $(name.ToUpper)
, so the parser knows how much is interpolation and how much is the literal part of the string.
Um, cool... I guess. So, this was intended behavior ?
Yeah. Did you ever figure out what was going on with the parse error?
Consider following sample:
Do you expect it to work ? Me too. However, compiler disagree:
What could be done ? Is it bug or somewhat intended restriction ?