Should the comma operator be removed in D2?

Adam D. Ruppe destructionator at gmail.com
Mon Nov 16 14:34:46 PST 2009


On Mon, Nov 16, 2009 at 10:12:57PM +0000, dsimcha wrote:
> Can someone please explain to me what the comma operator does? 

	a = b, c;

Is the same as:

	b;
	a = c;

In the comma operation, the first thing is evaluate, and its result discarded.
Then, the second thing (after the comma) is evaluated. The overall result
of the comma operator is the result of the second statement.

	1, 2 == 2

The usefulness is putting two statements together, where it only expects
one, like inside the for loop, where the semicolon moves you on from the
initialization to the condition.


-- 
Adam D. Ruppe
http://arsdnet.net



More information about the Digitalmars-d mailing list