4 ms·
"Think the ternary operator, but worse" Giving the developer succinct ways to prevent program failure from unexpectedly undefined values is a feature.
by crusso 7y ago
"Think the ternary operator, but worse"
Giving the developer succinct ways to prevent program failure from unexpectedly undefined values is a feature.
- ChrisMarshallNY 7y ago"Giving the developer succinct ways to prevent program failure from unexpectedly undefined values is a feature." Most languages have had this since the 1960s. It's called the "if" clause. The ternary and nil-coalescing operators are shorthand (sugar) for an if test (or guard, in Swift). Like I said, I actually like them, but I have to be careful, when using them. I really like Swift, but it's quite possible to write completely inscrutable code in it.
- eugeniub 7y ago> Most languages have had this since the 1960s. > It's called the "if" clause. If we got rid of everything we don't absolutely need in programming, we would have to get rid of 98% of Swift syntax, and probably every modern programming language including Swift.
- ChrisMarshallNY 7y agoYes, but I LIKE Swift, because of all that sugar. I started off with machine language, in embedded systems. You can't get much more "raw" than that. I have been writing Swift exclusively for a long time. I speak it without an accent. It's my beauty. But I also know that you can have so much sugar you fall into a diabetic coma.
- FpUser 7y ago>But I also know that you can have so much sugar you fall into a diabetic coma. Exactly my feelings. Same thing here started from machine code and now doing everything else including kitchen sink
- megous 7y agoDid you guys really start from machine code or do you mean assembler?
- ChrisMarshallNY 7y agoMachine. Hex keypad and a lot of looking up hex codes for commands. Type in a bunch of numbers, then set the PC to 0. Assembler was great after that. I do not remember that stuff fondly. It sucked.
- FpUser 7y agoMachine code. Was actually typing it on big roll of paper and then crawling around it pretending to be a debugger
- leshow 7y ago> It's called the "if" clause. "If" is often a statement, not an expression, so they aren't equivalent in a lot of cases. I'm not sure if this is the case in Swift, but I'm fairly certain that Swift's '?' operator also does unwrapping and propagation, similar to '?' in Rust.