std.stdio.writeln
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Mar 9 07:48:19 PDT 2015
On Monday, 9 March 2015 at 14:38:41 UTC, Dennis Ritchie wrote:
> Hi.
> Why prints only the last element?
>
> import std.stdio;
>
> void main() {
>
> (1, 2, 3).writeln; // prints 3
> }
I think this is a misunderstanding about UFCS.
1.writeln(2, 3);
is the same as
writeln(1, 2, 3);
and the same as
(1).writeln(2, 3);
but
(1, 2, 3).writeln;
is completely different. UFCS is only for the first argument.
Yet another excellent example of why we should abolish the comma
operator in D.
More information about the Digitalmars-d-learn
mailing list