values = [ "a", "b", "c", "a", "d" ] p values.each_index.select {|i| values[i] == 'a'}p values.size.times.select {|i| values[i] == 'a'}
Standard input is empty
[0, 3] [0, 3]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!