Jedi

add support for first() taking a filter

Details

  • Type: New Feature New Feature
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    1

Description

first(collection, filter) will return the first element of collection matching filter

Activity

Hide
Mike Hogan added a comment -

Patch to implement this

Show
Mike Hogan added a comment - Patch to implement this
Hide
Lance Walton added a comment -

Thanks for the patch, Mike.

I've modified it a little so that the behaviour in the case of no items matching and empty collections is concistent with the rest of Jedi (e.g. it throws an exception).

Your original version is now named firstOrNull.

I've also added firstOrDefault and firstOption.

Show
Lance Walton added a comment - Thanks for the patch, Mike. I've modified it a little so that the behaviour in the case of no items matching and empty collections is concistent with the rest of Jedi (e.g. it throws an exception). Your original version is now named firstOrNull. I've also added firstOrDefault and firstOption.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: