-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: introduce first_opt()
, first_key_opt()
, last_opt()
, last_key_opt()
and search_opt()
#467
Conversation
I like the idea of returning an
cc @veewee this might interest you. |
I'll go for it. Thanks for input. |
The migration path might be better this way indeed.
|
@veewee personally i would like to keep both, i don't see why we need to deprecate/remove the old behaviour. |
first_opt()
, first_key_opt()
, last_opt()
, last_key_opt()
and search_opt()
Pull Request Test Coverage Report for Build 8953186695Warning: This coverage report may be inaccurate.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.
Details
💛 - Coveralls |
…_key_opt()` and `search_opt()`
Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one last thing 😅
src/Psl/Iter/search_opt.php
Outdated
* Examples: | ||
* | ||
* Iter\search(['foo', 'bar', 'baz'], fn($v) => 'baz' === $v) | ||
* => Str('baz') | ||
* | ||
* Iter\search(['foo', 'bar', 'baz'], fn($v) => 'qux' === $v) | ||
* => Null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exampless are outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. is it correct now? Not sure what Str('baz')
was, replaced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
…_key_opt()` and `search_opt()` (azjezz#467) * feat: introduce `first_opt()`, `first_key_opt()`, `last_opt()`, `last_key_opt()` and `search_opt()` * Update src/Psl/Iter/last_opt.php Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com> * Update src/Psl/Iter/search_opt.php * example --------- Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>
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?