[Vala] interaction of parentheses and string template interpolation via the @ sign



If you do string interpolation via
    string s = @"some text $some_variable";
it produces a string like
    some text 5
if 5 were the value of some_variable.

But if you put parentheses in, this gets defeated:
    @("some text $some_variable")
just becomes
    some text $some_variable
with no interpolation of the value of some_variable into the string.

Is this intentional?

This is with vala 0.28.1 on ubuntu 15.10.

(And of course it is a very tiny issue, if it is an issue at all.  The reason it
came up in the first place was i had something more complicated,
   @("a: $a\n" +
        "b: $b\n" +
        "c: $c\n")
and i was very surprised that this did not work.  It can be fixed by the
slightly lengthier form
    @"a: $a\n" +
    @"b: $b\n" +
    @"c: $c\n"
but i do wonder why grouping with parentheses has such a drastic effect.
And it also makes me wonder just what @ does and what it sees: clearly
it has greater visibility into its surroundings than just some function.)

Thanks in advance for any info.

dan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]