Ruby_Arrays Flashcards
Programmers tend to call a bunch of stuff grouped together a collection of ….
….objects.
The most useful collection of objects, in ruby is an ..
an array
Arrays that don’t contain items are called …
empty arrays
The ( ? ) method is a way to add an item to the array.
push
The push method we use the ( ? )
The append operator “.push”
What does
array = [ ]
mean?
The [ ] indicate an empty array, but between the square brackets we can put a comma-separated list of the values the array will contain.
What 3 strategies are used to create arrays?
Using push, the shovel operator or entering an actual array.
How can you tell that the value is actually an array containing multiple strings.
=> “They’re peanut butter and jealous!”, “It’s not a man-purse. It’s called a satchel. Indiana Jones wears one.”, “Rule Number 76. No excuses! ]
array.inspect
this inspects the code and will tell you its an array: the output looks like this:
[“They’re peanut butter and jealous!”, “It’s not a man-purse. It’s called a satchel. Indiana Jones wears one.”, “Rule Number 76. No excuses!
Programmers will use the word iterate to mean …..
to go through each of the items one-by-one.
What does adding the “upcase” do?
Ex below:
quotes.each do | quote |
upcase_quote = quote.upcase
puts upcase_quote
end
Capitalizes all the letters.
What actually happens when we call the upcase method?
Calling it, stores the result in a variable. We then can display the result of the string with all uppercase letters on the screen.
Arrays that don’t contain items are called:
empty arrays.