Settings

Theme

Nested String Interpolation in Groovy

tomisawesome.com

2 points by 00kevn 6 months ago · 1 comment

Reader

DecoPerson 6 months ago

The syntax highlighter not understanding GStrings (heh) doesn't help here.

It's obvious once you release that whatever is inside a GString is simply an expression.

    def expr = foo."${baz}"
    println("Bar value: ${expr}")
This makes sense.

But this, or any of the other variations...

    def expr = foo." + baz + "
    println("Bar value: ${expr}")
...does not make sense.

If the syntax highlighter understood GStrings, then this would be obvious.

Let S be string colour and _ be non-string colour:

    println("Bar value: ${foo."${baz}"}")
    ________SSSSSSSSSSSSSS____SSS___SSSS_

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection