user88482
0
Q:

get size of array in ruby

[ 1, 2, 3, 4, 5 ].length   #=> 5
[].length                  #=> 0

". length" will get size of array
3
# Ruby code for length() method 
  
# declaring array 
a = [18, 22, 33, nil, 5, 6] 
  
# declaring array 
b = [1, 4, 1, 1, 88, 9] 
  
# declaring array 
c = [18, 22, 50, 6] 
  
# length method example 
puts "length() method form : #{a.length()}\n\n"
  
puts "length() method form : #{b.length()}\n\n"
  
puts "length() method form : #{c.length()}\n\n"
1

New to Communities?

Join the community