And don't you dare to assign aliases to other objects in those languages! It just looks and feels...wrong! Is it mutable? Is is not? Does it get cloned? Oh my what happens here?!😲 What...a thread!?😱
@janriemer lol yeah! after working with Rust for a while I now feel dirty when using other languages and leaving unnecessary references everywhere.
But on the other hand I enjoy the fact that I don't need to .unwarp().unwrap().unwrap() everything.
@sergrass > But on the other hand I enjoy the fact that I don't need to .unwarp().unwrap().unwrap() everything.
Yeah, until you look at a bigger codebase and then have to ask yourself: "oh, can this value be null? And what is this "connect()" thing doing? Can it fail? Hm...looks like a third party lib. So do I have time to look at the docs now? Na, what can go wrong!?"
#Rust is about being explicit and I've never encountered a situation, where this is a bad thing.
@sergrass When one has to call .unwrap().unwrap().unwrap() (btw one should rather handle the Error/None case instead of panic), it _shows the complexity of the problem/data structure at hand_.
In other languages this only gets hidden away - the underlying complexity is the same and one needs to deal with it somehow (or not deal with it at all and get thrown a NullPointerException in the face).
@sergrass @janriemer Yeah. Sometimes, rather than unwrapping an error value, you can apply methods to it which will preserve any error and operate on an ok value. Similarly for Option. That reduces the number of unwraps.
Also, if you "want the simplicity of unwrap without the possibility of a panic", the question mark operator "?" has you covered 😉
In this case, you might be able to use some kind of "DUMMY" value.
If the Rust compiler uses this "trick" with their "NodeId" values in their AST, you know that this might be worth looking into😉:
As I said, this is really an exception. Please use `Option`.🤓
This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!