4 ms·
See also: "What is the "-->" operator in C++?" https://stackoverflow.com/q/1642028 https://stackoverflow.com/q/1642028
by rdlw 4y ago
See also: "What is the "-->" operator in C++?"
https://stackoverflow.com/q/1642028 https://stackoverflow.com/q/1642028
- teawrecks 4y agoYeah, I thought this was going to involve the ternary operator. TIL about trigraphs.
- sargstuff 4y agostill can, just have to add precidence changing characters ( )
- LorenPechtel 4y agoYeah, C# has some shortcuts these days of the form x <symbol>= y that compile as x = x <symbol> y. They are an actual advantage as x only needs to be stated once and it is absolutely clear that is assignment into the value--more information readily communicated with fewer characters. It also has the null coalescing operator ??. Put those together and you can have x ??= y (if (x = null) x = y;)--useful for lazy initialization and it can be returned, making lazy initialization getters much clearer. This looked awfully similar, I was trying to figure out how you could negate null coalescing.
- pjmlp 4y agoThese days, like since C# 1.0.
- tuukkah 4y agoIt's interesting to see the history of any given piece of syntax. This specific one is called augmented assignment or compound assignment: https://en.wikipedia.org/wiki/Augmented_assignment https://en.wikipedia.org/wiki/Augmented_assignment +:= in Algol68 =+ in B += in C
- furyofantares 4y agoAnd sort of the opposite of that, I once had someone say they wanted to contribute to the C++ portion of our codebase, but the only problem was they didn't know how to make the "->" character, and did they need to get a special keyboard?
- icambron 4y agoIs it possible that their editor provided ligatures but they didn't know about those and so assumed it was actually a character in the source?
- furyofantares 4y agoNo, it was much too long ago for that. They were just very new to programming and had interpreted it wrong the first time they saw it (most likely in a book, that's how we used to get our first introduction to a language).
- Izkata 4y agoSemi-related: One of the people on my team uses a font that displays things like ">=" as "≥". I was a bit confused the first time I saw it.
- falcor84 4y agoAnd of course, its cousin the slides-to operator, described in the answer https://stackoverflow.com/a/8909176/493553 https://stackoverflow.com/a/8909176/493553 with the following example: while (x --\ \ \ \ > 0) printf("%d ", x);
- DonHopkins 4y agoWhenever somebody complains about how Python uses indentation instead of { } or BEGIN END, you can prove to them that it actually does support that and more, by demonstrating that they simply need to prefix their favorite brackets or keywords with Python's unary "#" operator, like: for i in range(10): #{ print(i) #} or: for i in range(10): #BEGIN print(i) #END You can even mix-and-match them, like: for i in range(10): #BEGIN print(i) #} or: for i in range(10): #{ print(i) #END or turn them inside-out, like: for i in range(10): #} print(i) #{ or: for i in range(10): #END print(i) #BEGIN Python is extremely flexible that way, and can easily strangle and eat all other languages.