Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby get the number of same element in array

names = ["Jason", "Jason", "Teresa", "Judah", "Michelle", "Judah", "Judah", "Allison"]
counts = Hash.new(0)
names.each { |name| counts[name] += 1 }
# => {"Jason" => 2, "Teresa" => 1, ....
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ruby #number #element #array
ADD COMMENT
Topic
Name
9+3 =