3 ms·
Has anyone tried to make null as a function? In Julia, there is a `get(null::Function, collection, key)` method which can be used in a syntax: value = get(coll
by JanisErdmanis 2y ago
Has anyone tried to make null as a function? In Julia, there is a `get(null::Function, collection, key)` method which can be used in a syntax:
value = get(collection, key) do
error(“$key in the collection not found”)
end
This syntax has captivated my attention lately as it seems like a viable alternative to doing an explicit null check before using the value.
- masklinn 2y agoThat’s just a default callback. Actually using this instead of nulls in any sort of general case would be using CPS for all faillible APIs, and that sounds heinous.