However, I will limit it to pure 'objects'. No pointers or ref. No basic types. Strictly objects.
And, just like the regular nullable types, the following WILL work if at all possible:
type
User = object
name: string
age: int
var u: Nullable[User] = User(name: "Larry")
var x: Nullable[User] = nothing(User)
var y: Nullable[User] = null(User)
var z: Nullable[User] = ValueError(msg: "something went wrong")
Example code from Option[T]:
https://github.com/nim-lang/Nim/blob/d53ab9e5c857d47b8ea9643a2cf0235f3486afa0/lib/pure/options.nim
However, I will limit it to pure 'objects'. No pointers or ref. No basic types. Strictly objects.
And, just like the regular nullable types, the following WILL work if at all possible: