Hacker News new | ask | show | jobs
by empath75 2289 days ago
I’m a community college drop out and have never taken a CS class and I use options in my code all the time.

It’s just a wrapper around some value that is either Some(value) or None and you need to unwrap it and handle both possibilities for your code to compile.

You don’t need to know anything about monads or ADT’s to understand it.

1 comments

But do you understand that some values of a 32 bit int can be used to encode meta-data about a 8 bit char?

If you understand both, which one is conceptually easier to you?

Option<T> is conceptually easier because:

1) It applies exactly the same way to any type, not just char.

2) You don't need to read the man page for every single function that returns an int on the off chance that said int actually contains a bool, a char, or a short plus additional flags.

option obviously.

I just do not understand what the problem with Option is.

It's either Some(1) or None. If it's some you have the value, otherwise you handle the fact you don't have it.

It's so simple and basically every modern language uses it to handle nullable types.

Options for sure, at least in rust.

Rust has tons of help dealing with options built into the language.