Ah, I am so happy to be writing Swift nowadays. You can never return null unless you specifically say so in your type, and you have to always have code that handles the nulls.
Still, documenting all the possible reasons something might return null would still be great.
Conversation
You can have your cake and eat it too - you just explicitly 'opt-in' to nullability when you want it. In some languages you call it `T?`, in others it's `Option<T>`. Swift, Rust, Kotlin, C# 8.0, Haskell, etc. all have this lovely feature - thankfully it's becoming more popular!
2
1
It is a generic type, it means it’s a value of type T, or possibly null.
1
Yeah, in Rust for example you have:
enum Option<T> {
Some(T),
None,
}
So it can either be something or nothing. No value can ever be null in Rust, so it effectively gives you opt-in nullability. Likewise you have:
enum Result<T, E> {
Ok(T),
Err(E),
}
1
Yeah, I got into Rust for gamedev because I was avoiding C++ - never got around to making a game though 😬. There's a nice bunch of peeps who like to mess around with game stuff in Rust though! Also audiophiles like :)
1
2
I saw this stuff recently too:
- youtube.com/watch?v=Yom9E-
- synthesize.rs/nov-2018-talk/
Hope that helps!
Oh, and I'm a long time lover of Knytt and Knytt Stories btw... they had a big affect on me back in the day. Thanks for making those lovely worlds! 🤩
Evidence:
Quote Tweet
Replying to @managore
Kyntt scurrying up a wall with the cute lil sound effects
1
1
I still have the memory of those weird llama things in the cave with rushing sound of the waterfall…
Replying to
Thanks! I'll check it out! The silly thing about me is the main reason I want to pick up Rust is that I swear every time I have to write another header file in C++ when doing synthesis work.
1
Show replies


