You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Supported a built-in None value that works for all T.
NONE = option.None[Dyn] <: option.None[T] for all T.
Note that NONE is equivalent to option.None[Dyn].
Still to implement:
The implicit conversion from T to T?.
// this will convert "Hello" to option.Some[String]("Hello").valstr:String?="Hello"
Support "!" operator that explicitly convert T? to T, raise an error if str is NONE.
// this will convert type of str from "String?" to the type of str2 "String".valstr2:String= str!
Propagate None using ?. operator.
typeNestedvalstr:String?valn1:Nested?=newvalstr:String?="Hello"// this will print "Hello" successfully.
stdout.print(n1?.str.get())
valn2:Nested?=NONE// this will print "NONE", since n2 is of NONE type, "?." operator is used to propagate NONE.
stdout.print(n2?.str.get())
valn3:Nested?=newvalstr:String?=NONE// this will print "NONE, since n3.str is of NONE type, "?." operator is used to propagate NONE.
stdout.print(n3?.str.get())
See the design at https://github.com/wyvernlang/wyvern/wiki/Sugar-for-Options
The text was updated successfully, but these errors were encountered: