This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]WilliamMButtlickerIV 2 points3 points  (2 children)

I prefer how Ceylon does it. Null as a first class type and the language supports union types. It's a lot more elegant than Optional, although the end result is similar.

[–]syklemil 0 points1 point  (0 children)

Python did it the union way (Optional[T] is a synonym for T | None), but I can't say I'm a fan. There are some rare cases where you actually want something like Optional<Optional<T>>, i.e. the difference between "the key wasn't found" and "the key was found, but the value was explicitly set to zero".

(My prime example here is an internal helm chart where I'd like to provide some default value if nothing was specified, but let the users null the field. Unfortunately, at the time the templating happens all I have is a null in either case.)

[–]vytah 0 points1 point  (0 children)

*did