ruby on rails - RoR array -count identical elements-on including value -


how count idential values on after appending value in array

such that

a=[]  a<<1 count of 1 1  a<<1 count of 1 2 

thanks

you do:

a.select{|v| v == 1}.size 

it's 1 solution


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -