fuzion
fuzion copied to clipboard
`option` (indirectly) inherits from `Sequence`: unexpected behavior
$ cat ex_option.fz
ex_option =>
x option i32 := nil
y String := x.as_string ""
say y
$ fz ex_option.fz
this works like if someone had intended to use x.get "", but it doesn't work for x.get "something else". this is because Sequence has as_string taking a separator argument.
we should reconsider having option (by means of switch) inherit from Sequence.
The behavior in your example is surprising, but I think you can run into a similar surprise call as_string on a Sequence, maybe we should rename as_string (one argument)?
I very much like to be able to treat an option as a Sequence of length 0 or 1.
option no longer inherits from Sequence: #4734