ruby check array contains all elements from another array code example

Example 1: get element of an array inside another array

let array=[[1,2,3],
           ["apple","mango","grapes"],
           [true true false]]
//to get apple =====  arrayName[class][subclass]
console.log(array[1][0])

Example 2: 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, ....

Tags:

Ruby Example