#1312 Comma operator example in Expressions docLang

Henri Sat 13 Nov 2010

Is the first example of in http://fantom.org/doc/docLang/Expressions.html#collections correct? Shouldn't the third line read:

a, b, c,  =>  it.add(a).add(b).add(c)

(note the comma after c)?

brian Sat 13 Nov 2010

No you actually do not need the trailing comma - that is only required if you have one item to add. Simple example:

echo( [,] { 1, 2, 3 } )

Henri Sun 14 Nov 2010

If I understand correctly, the second line of that same example could also read:

a, b    =>  it.add(a).add(b)

instead of:

a, b,    =>  it.add(a).add(b)

?

brian Sun 14 Nov 2010

If I understand correctly, the second line of that same example could also read:

Yeap you understand correctly.

Actually probably should remove that trailing comma from docs

Login or Signup to reply.