Mega Code Archive

 
Categories / Ruby / Array
 

Use until and array element to loop through an array

array = ['cherry', 'strawberry', 'orange'] index = 0 until index == array.length   puts "At position #{index}: #{array[index]}"   index += 1 end