array_list = ["milk", "eggs", "bread", "ice cream", "pie", "potatoes"]
Accessing "milk" and assigning it to variable named "item"
item = array[0]
Printing first item in array:
puts.array.first
Printing out last item in array:
puts array[-1]
puts array.last
Return the number of items in an array:
array.length
array.count
Return the number of items in the array based on the matches found:
array.count("eggs") # => 1
To find out if a specific item is on the array list:
array.include?("eggs") # => true
Top comments (0)