So, I’ve been reading the docs a lot lately. The FAQ has this crazy thing about nothingness that just raises more questions. I get nothing
, and I get Union{T,Nothing} where T
and use it frequently. That’s fine. I have two main things I want to know:
There is this sentence:
Note that the compiler is able to generate efficient code when working with
Union{T, Nothing}
arguments or fields.
That sounds great. Does that work on arrays? can I have efficient arrays of nullable types? Should I be doing something else if I want to preallocate a large array and fill it later? (can I turn Julia into C? )
OK, next question. What is this Some
and something
stuff? I think I understand the conceptual difference between nothing as a value and nothing as the absence of value (I’ve had to write my private “empty” objects in other languages to mark the absence of a value where I’m handling data structures in a library and the API-user’s nil/null/None is a value, as far as the library is concerned)
I understand that something
and Some(nothing)
are somehow related to these usecases, but I really have no idea exactly how or where to use them. Can someone give an example or two?