W1 Flashcards
SyntaxError
Incorrect grammar in the structuring of the ruby code
Ex: my_array =
Need to have a value assign to it
NameError
A variable or method name that has not been defined
Ex: my_name = yangel
P name
Name was not previously defined
NoMethodError
Refers to a undefined method. It is
Considers a SPECIAL instance of a NameError
Ex:
def say_hello(name)
P “hi” + name
end
hello(“world”)
Because “hello” is not defined method
ArgumentError
Results of typically passing too little or too many arguments
Ex:
def say_hello(f_name, l_name)
p “hi” + f_name + “ “+ l_name
end
say_hello(“yangel”)
We only gave 1 argument when needing 2
TypeError
Result from performing an operation with a incompatible data type
5 + “spaghetti”
all?
Returns true when all elements in result in true when passed into the block
any?
Returns true when any of the elements results true when passed into the block
none?
Returns true when no elements of result in true when passed into the block
one?
Return true when exactly one element result in true when passed into the block
.count
Return a number representing the count of elements that result in true when passed into the block
.sum
Return the total sum of all elements
.max and .min
Return the maximum or minimum element
.flatten
Return the 1 dimensional version of any Multidimensional array
Symbols
Symbol and string are not equivalent. Symbols are immutable.
sym = :hello
*
Splat operator accepts additional arguments
The additional argument will be in a array
Best practice to put * at the end of the parameter
** performs similar unpacking of a hash key value pairs ( will only work with hashes where keys are symbol: )