print takes whatever and prints on screen
puts adds new line after what is presented
Front
puts and print
Back
for false statements to run
Front
unless in Ruby
Back
three dots exclude last number
two dots include the last number
Front
inclusive and exclusive ranges
Back
collection of all variables and their values that exist in the program at a given time
Front
environment in Ruby
Back
using iterator; invokes block of code
Front
loop method in Ruby
Back
word or name that grasps a single value
name = value
Front
variable in Ruby
Back
if/else
if 1 > 2
print
else
print
end
Front
else in Ruby
Back
used to skip over certain steps in the loop
Front
next in Ruby
Back
type code in editor, interpreter reads code, and shows the result in the console
Front
editor
Back
apply expression to each element of an object, one at a time
Front
.each in Ruby
Back
logical/boolean operators
and; &&
or; ||
not; !
Front
and in Ruby
Back
Section 2
(32 cards)
reverses the sequence
Front
reverse!
Back
a parameter
what .each has been doing: taking block as parameter
Front
a method can take a block as
Back
.each_key
.each_value
Front
only working with keys or values
Back
block disappears after performing
Front
blocks vs. methods
Back
always start with colon (:)
valid Ruby variable name (first character has to be letter or underscore)
Front
how to write symbols
Back
way of creating methods that don't have a name
defined with either keywords do and end or with curly braces
Front
blocks
Back
Front
default value for hash
Back
along with false, one of two non-true values
Front
nil
Back
1. header (def, name of method, and arguments)
2. body (describes procedures of method)
3. end
Front
three parts of methods
Back
reusable section of code written to perform specific task
Front
method
Back
make it into a string
Front
to_s
Back
else when any of when statements does not match
Front
case statement
Back
make good hash keys
1. immutable; can't be changed once created
2. only one copy exists; save memory
3. faster than strings-as-keys
Front
properties of symbols
Back
Front
iterating in hashes
Back
arguments preceded by *
use when don't know how many arguments there are to be, but could be more than one
Front
splat arguments
Back
filtering hash for values that meet certain criteria
Front
.select
Back
by just typing the name
Front
calling a method
Back
keyword def
Front
methods are defined using
Back
.to_s
.to_sym
.intern (same as .to_sym)
Front
symbols to strings and vice versa
Back
1. colon at end of symbol
2. don't need hash rocket
Front
new hash syntax
Back
compare two objects
<=>
returns 0 if first operand (item to be compared) equals the second
1 if first operand is greater than the second
-1 if first operand is less than second
Front
combined comparison operator
Back
method not to print something to the console but to hand us (or another method) a value
Front
return
Back
Front
iterating in multidimensional arrays
Back
Front
setting default value for hash
Back
it accepts or expects the arguments
argument; piece of code actually put between method's parentheses when calling
parameter; name you put between the method's parentheses when you define it
Front
if a method takes arguments
Back
sort the array
returns array of arrays
Front
.sort_by
Back
.sort! method
.sort sorts a copy
while sort! destroys the original and replaces with sorted version
Front
sorting
Back
sort of a name
symbols are not strings
key behavior; while there can be multiple different strings that all have the same value, there's only one copy of any particular symbol at a given time
two "strings" are different objects
while two :symbols are the same object
Front
symbols in Ruby
Back
second parameter will default to false if user doesn't type in two arguments
Front
two parameters in method
Back
Front
two ways of creating hashes
Back
great way of abstracting certain tasks from the method and defining those tasks when we call the method