Constructors from Optional Variants? #448
migueldeicaza
started this conversation in
Ideas
Replies: 1 comment
-
🌝I think it’s also good to use Optional.flatMap:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
One idiom I keep running into is extracting values out of a Dictionary (which could be nil) and then having to add extra code to convert it to t a value:
Like this:
then try to convert this to say, a String, or Int or whatever else, with the constructors that take a "Variant":
I am tempted to add failable constructors that take a "Variant?" rather than just a Variant:
They are already failable, but this would extend it to allow optionals
So I could write
Are there any downsides I might not be anticipating?
Beta Was this translation helpful? Give feedback.
All reactions