Reputation: 19
I have:
a = [1,2,4,5]
I want to modify this array to get:
a #=> [1,0,0,0]
This can be done with an each
loop, but I'm trying not to use a loop here. Here's my code:
a.values_at(1..3).map! {|i| i = 0}
Upvotes: 0
Views: 81