Skip to content

Commit

Permalink
Add return type restriction to Enumerable#index_by (#10858)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota authored Jul 12, 2021
1 parent 27dea13 commit 1d5b6a9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/enumerable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ module Enumerable(T)
# ["Anna", "Ary", "Alice", "Bob"].index_by { |e| e.size }
# # => {4 => "Anna", 3 => "Bob", 5 => "Alice"}
# ```
def index_by(&block : T -> U) forall U
def index_by(&block : T -> U) : Hash(U, T) forall U
hash = {} of U => T
each do |elem|
hash[yield elem] = elem
Expand Down

0 comments on commit 1d5b6a9

Please sign in to comment.