Use while and array index to get element from an array : Array Index « Array « Ruby
- Ruby
- Array
- Array Index
Use while and array index to get element from an array
array = ['cherry', 'strawberry', 'orange']
index = 0
while index < array.length
puts "At position #{index}: #{array[index]}"
index += 1
end
Related examples in the same category