Mega Code Archive

 
Categories / Ruby / Array
 

Use the arrays built-in length method, which returns the number of elements in the array

array = ["Hello", "there", "AAA", 1, 2, 3] puts array[1]       #prints "there" puts array[4]       #prints 2 puts array.length   #prints 6