• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/19

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

19 Cards in this Set

  • Front
  • Back
  • 3rd side (hint)
?
conventional in Ruby to have '?' at the end of the method if that method returns only boolean values
@
instance variable
lambda
lambda is just a function... peculiarly... without a name. They're anonymous, little functional spies sneaking into the rest of your code. Lambdas in Ruby are also objects, just like everything else!
convention is to use {} for single line lambdas and do..end for lambdas that are longer than a single line.
Lambdas vs. Blocks
A lambda is a piece of code that you can store in a variable, and is an object. The simplest explanation for a block is that it is a piece of code that can't be stored in a variable and isn't an object. It is, as a consequence, significantly faster than a lambda, but not as versatile and also one of the rare instances where Ruby's "everything is an object" rule is broken.
most common uses for a lambda
one of the most common uses for a lambda involves passing exactly one block to a method which in turn uses it to get some work done. You'll see this all over the place in Ruby - Array iteration is an excellent example.
module
Modules only hold behaviour, unlike classes, which hold both behaviour and state.

Since a module cannot be instantiated, there is no way for its methods to be called directly. Instead, it should be included in another class, which makes its methods available for use in instances of that class.
::
:: is a constant lookup operator that looks up the Array constant only in the Perimeter module.
symbol, ex :octocat
immutable string whose value is itself, typically used for enumeration. its own primitive type
used in Ruby to denote "specialness" such as being one of the set of fixed choices like an enumeration. Symbols can easily be converted back and forth with the methods to_s and to_sym.
return value of puts versus return value of addion
always nil versus sum
1+1 returns 2
primitives versus objects
primitives dont have a common relationship to each other
variables
will always be undefined or ACT like an object
they are not objects
variable scope indicators
Global $variable
Class @@variable
Instance @variable
Local variable
Block variable
array
An array is an ordered integer- indexed collection of objects.
That's a very fancy way of saying that we can take objects and put them together in order, and keep their position in the same order, and we can refer to those objects by their positions.
Expanding file folder is good analogy because folders can be empty. Classes can be put in arrays, expa
a.b means: ____ ____ b on ______ a
•a.b means: call method b on object a
•a is the receiver to which you send the method call,
assuming a will respond to that method
•does not mean: b is an instance variable of a
•does not mean: a is some kind of data structure
that has b as a member
def by_three?
best practice to end methods with a question mark if they return a boolean in ruby
blocks
create a method with no name. Blocks can be defined with either the keywords do and end or with curly braces ({}).
is 0 true of false
0 or empty string is true. False and nil are the only things that are true. They are not the same thing but they both return false
what is returned by default from a method?
- if a method does not explicitly return a value, the last expression’s value is returned, ex
poetry mode
omit paretheses around arguments to a method call, and omit curly braces when LAST argument to a method call is a hash
there's a single hash argument, and its the last argument