user2369480
user2369480

Reputation: 71

ruby array with arrays how to get the array number when iterating over each of them and searching by number

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

Answers (1)

ReggieB
ReggieB

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

Related Questions