3 ms·
Small change made in swift means an unwrap can just be `if let x { }` Which while small, is great if you do it all the time. Swift though made me question ho
by secretsatan 3y ago
Small change made in swift means an unwrap can just be
`if let x {
}`
Which while small, is great if you do it all the time.
Swift though made me question how much I used optionals, now I get annoyed if they're over used, it usually means someone down the line has not made a decision, they propagate through the program and eventually someone wonders why they didn't get a value.
I like the Result type and the Flexibility of the Enums a lot for this
- secretsatan 3y agoTbh, i now look at optionals as another colour when i read this https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ https://journal.stuffwithstuff.com/2015/02/01/what-color-is-... You return an optional with no reason, it colours all subsequent calls. When i was younger, i thought of them as an extension of bool, yes/no/maybe, but now, was it cancelled? Did an error occur? Did it just timed out? How many cpu cycles am i wasting throughout my code because every thing down the line checks it for null? It snowballs