Skip to content

Commit

Permalink
Remove Slice#map
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Nov 20, 2024
1 parent f0873e2 commit 44d158b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/slice.cr
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,9 @@ struct Slice(T)
# slice.map &.to_s # => Slice["1", "2.5", "a"]
# ```
def map(*, read_only = false, & : T -> _)
Slice.new(size, read_only: read_only) { |i| yield @pointer[i] }
map_with_index(read_only: read_only) do |e|
yield e
end
end

# :inherit:
Expand Down

0 comments on commit 44d158b

Please sign in to comment.