Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/indexable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ module Indexable(T)
# [1, 2, 3, 4].find(-1) { |i| i > 8 } # => -1
# [1, 2, 3, 4].find(-1, 2) { |i| i < 2 } # => -1
# ```
def find(if_none = nil, offset : Int = 0, & : T ->)
def find(if_none = nil, *, offset : Int, & : T ->)
offset += size if offset < 0
return if_none if offset < 0

Expand All @@ -830,6 +830,11 @@ module Indexable(T)
if_none
end

# :ditto:
def find(if_none, _offset offset : Int, & : T ->)
find(if_none, offset: offset) { |e| yield e }
end

# Returns the first element in the indexable for which the passed block
# is truthy, starting from the given *offset*.
# Raises `Enumerable::NotFoundError` if there is no element for which the block is truthy.
Expand Down