Reputation: 71
if I get from params something like a 165. and this is number contains in array number 3 of 9. how to get this number of the array?
range = 50..450
cutter = range.last/50
b = range.each_slice(range.last/cutter).to_a
b #=> [[50, 51,..., 99],..., [400, 401,..., 450]]
How to get it?
Upvotes: 0
Views: 62
Reputation: 8257
The array method you want is find_index
. I think this will do what you want:
b.find_index {|a| a.include?(165)}
Upvotes: 2