4 ms·
> the `(0, funcName)` syntax works by evaluating each item in the parens, but returns the last item. This is just how the comma operator works in other languag
by saagarjha 8y ago
> the `(0, funcName)` syntax works by evaluating each item in the parens, but returns the last item.
This is just how the comma operator works in other languages such as C and C++: https://en.m.wikipedia.org/wiki/Comma_operator https://en.m.wikipedia.org/wiki/Comma_operator
- Klathmon 8y agoit is! And I just now realized that I have seen it used many times before, in for loops and variable declarations. It just seems so foreign and out of place when used outside of those instances though, and for me at least the purpose of it wasn't intuitive at all!
- mturmon 8y agoIn C, the commas are also used in macro definitions where you need multiple statements to be output by the macro, but can’t use semicolons because the macro might expand in a context where only one statement is expected. In both the OP and this one,it comes off as clever but tricky.