missing 'first' pipe
nirsalon opened this issue · 3 comments
nirsalon commented
I'm submitting a ... (check one with "x")
[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
Current behavior
No pipe returns the first element that matches a condition
Expected behavior
A new pipe, similar to 'where', that returns the first element that matches the condition
See .NET linq .First() https://msdn.microsoft.com/en-us/library/bb535050(v=vs.110).aspx
What is the motivation / use case for changing the behavior?
A more performant pipe than (arr | where:[cond])[0]
fknop commented
That's a good idea, what about the firstWhere
name ?
nirsalon commented
C# uses First()
, and FirstOrDefault()
which doesn't throw if not found
Java 8 uses findFirst()
Usually function names are either verb
or 'verbNoun', so I'd say something like first
/firstMatch
/findFirst
, but firstWhere
also work.