Begining Flashcards
What is the prompt?
The prompt. Typing code into the prompt gives you an answer.
What is a string?
A string is a set of characters the computer can process.
Imagine the letters are on a string of laundry line and the quotes are clothespins holding the ends. The quotes mark the beginning and end.
What are numbers and strings in Ruby?
Numbers and strings are Ruby’s math and text objects.
What are methods?
Methods are actions!
You’ve used English-language methods like reverse and symbolic methods like * (the multiplication method).
What converts things to strings?
to_s converts things to strings.
What converts things to integers?
to_i converts things to integers (numbers.)
What converts things to arrays?
to_a converts things to arrays.
What are arrays?
They are lists for storing things.
Arrays are lists for storing things in order.
Typed in a pair of brackets, e.g., : [12, 37, 43 ].
What is a list?
Lists store things in order.
Like standing in line for popcorn. You are behind someone and you wouldn’t dream of pushing them aside, right? And the guy behind you, you’ve got a close eye on him, right?
Here’s a list for you. Lottery numbers: [12, 47, 35].
What is an empty list?
[ ] is an empty list.
What is a variable?
A variable saves a thing and gives it a name.
Use an = sign, e.g., ticket = [14, 37, 18].
What are hashes?
The little dictionary with the curly pages { }
What are symbols?
Symbols are tiny efficient code words with a colon:
What are Blocks?
Blocks. Chunks of code which can be tacked on to many of Ruby’s methods. Here’s the code you used to build a scorecard: books.values.each { |rate| ratings[rate] += 1 }
Blocks are always associated with/attached to what?
Blocks are always associated with/attached to Methods.