Basics Flashcards
Ruby’s class for initializing I/O streams.
IO
Method for iterating through an array and storing the results in a new array
Array#collect
ie: array.collect { |elem| elem * 2 }
Method for iterating through an array and not storing the results in a new array
Array#each
ie: array.each { |item| puts item }
String method for breaking up the string into an array at certain points
String#split
||
this operator means…
or
&&
this operator means…
and
number > 0 ? “#{number} is positive” : “#{number} is negative”
this is an example of a ________ expression
ternary expression
[1, 2, 3][2]
this method will return:
3
the 2th index
Hash method which returns an array of all the hash’s keys
Hash#keys
method which returns an object’s class
Object#class
“hello”.is_a? String
what will this return and what is the method doing?
true
the method returns a boolean on whether the object is of the argument class
For a class to justify its existence, it needs to have two distinct features:
- State
2. Behavior
A ______ is a piece of code that you can store in a variable, and is an object.
lambda
a piece of code that can’t be stored in a variable and isn’t an object.
block