Closed simPod closed 5 months ago
I like the idea of returning an Option
, but i dislike having this type of BC, what about adding new functions that result in an Option
? e.g first_opt<T>(iterable<T> $i): Option<T>
vs first<T>(iterable<T> $I): null|T
?
_opt
suffix is one way to go about this ( this is a popular choice in the rust community, e.g: https://docs.rs/chrono/latest/chrono/struct.Date.html#method.and_hms_micro VS https://docs.rs/chrono/latest/chrono/struct.Date.html#method.and_hms_micro_opt), but i'm open to suggestions if you have any, maybe we can find a more suitable naming convention for those functions.
cc @veewee this might interest you.
I'll go for it. Thanks for input.
@azjezz
The migration path might be better this way indeed. However you'll probably end up to something that looks like this in the long run, which might be something we'dd want to avoid?
_opt
_opt
suffix and deprecate the _opt
suffix functions_opt
functions again@veewee personally i would like to keep both, i don't see why we need to deprecate/remove the old behaviour.
This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Totals | |
---|---|
Change from base Build 8832169884: | 0.01% |
Covered Lines: | 4415 |
Relevant Lines: | 4469 |
I'd like to modify search operations over
iterables
by wrapping the result in Option.Currently, it is not possible to use these functions to find
null
value sincenull
represents "no result".This applies to all
first*
,last*
andsearch
functions.WDYT?