An integer is a whole number, a float includes a decimal value
A bignum is a number that exceeds the storage capacity of a fixnum. I'm not sure at ### what point that distinction occurs, and I'm not sure what different methods are available on both.
2.0
1.0
The "*" is syntactic sugar (meaning shorthand) for a multiplication method. The "?" might also be sugar, but I'm not sure.
1
true How can you write 5 to the 2nd power? 5 ** 2
How can you grab the substring “ell” from “hello”? "hello"[1..3] Give an example of string concatenation and string interpolation. concatenation = "Hel" + "lo" interpolation = "Two plus two is #{2 + 2}" Give examples of three variable names: a “valid name” (it will work) that goes against Ruby style, an “invalid” name (it will trigger an error), and a valid and stylistically conventional name. bad style = javaScriptVar invalid = 1st_val good = times_bubbled
How do you add to an array? shoveling, pushing, shifting
return an array with those three values in random order. Possibly [3,1,2]
They insert and remove the first value from an array. Name 3 ways to retrieve 4 from this array: [4,3,5] [4,3,5][0] [4,3,5].first [4,3,5].unshift How would you print each word from this list (["hello", "goodbye", "cactus"]) to terminal within this output: The word is "hello". The word is "goodbye". The word is "cactus". array.each do |word| puts "The word is "#{word}"" end
A while loop operates if the condition evaluates to true, and the until loop iterates if the condition evaluates to false How do you escape a pry in the middle of a loop? exit
To operate on every value of a collection
do end && {} Given this array ["Beth", "Lauren", "Ilana"]. How would you create a new array of just the first initials of each name? new_array = [] array.each do |name| new_array << name[0] end
When you’re defining a class, how do you store attributes? Many different ways, but I believe a conventional method would be defining them in the initialize method
Read/write access.
I don't know. (Initialize)
Describe the scope that methods create. Are variables created in that scope accessible elsewhere?
A new, local scope is created when a method is defined. Variables within that scope are not accessible outside. It does not have access to global variables unless they are fed into the method as an argument.