Subject: Re: Array index question
From: Alex Baranosky <abaranosky@ t i c >
Date: Sun, 28 Feb 2010 15:55:50 +0900
References: 358060358064358065358074358186
In-reply-to: 358186
Here's my solution in 1.9:
class Array
def indices_of(value)
indices = self.each_with_index.select { |v, i| v == value
}.collect{|v, i| i }
indices.empty? ? nil : indices
end
end
--
Posted via http://www.ruby-forum.com/.