4 ms·
Realize in C and JS and most languages, the standard equality '=' operator, does exactly this. For example, console.log(2*(a = 10)) would print 20 while settin
by goldenkey 8y ago
Realize in C and JS and most languages, the standard equality '=' operator, does exactly this.
For example, console.log(2*(a = 10)) would print 20 while setting a to 10
- tytytytytytytyt 8y agoMost languages?
- reificator 8y ago> Realize in C and JS and most languages, the standard equality '=' operator, does exactly this. > For example, console.log(2(a = 10)) would print 20 while setting a to 10* `=` is the assignment operator, not the equality operator. The equality operator is `==` in C and `===` in JS.
- goldenkey 8y agoYou are correct, my mistake.
- marcosdumay 8y agoMost languages do not have that feature. Even the C-like languages usually have some comment by their designers claiming that C made mistake there and they are not adding it to their language.
- klibertp 8y agoIn C and JS assignment is an expression which returns the value being assigned. This makes the semantics of things like `a = b = 10` trivial. In Pony, though, this is averted, as the assignment there returns the old value of a variable being assigned: var a = 10 var b: Int b = a = 20 a == 20 and b == 10 // very true It's a very interesting approach I wish I saw explored more often.