• 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/7

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;

7 Cards in this Set

  • Front
  • Back

Define "DSL".

DSL = Domain Specific Language

What is an enumerable?

From RubyDocs: "The Enumerable mixin provides collection classes with several traversal and searching methods, and with the ability to sort. The class must provide a method each, which yields successive members of the collection."




Basically: curly brackets using "each" in lieu of a loop

What is the difference between an instance variable and a method in a class?

Instance variables are what the object knows, while methods are things an object does.




Source: http://rubylearning.com/satishtalim/writing_our_own_class_in_ruby.html



What two distinct features must classes have?

State and Behavior




source: http://rubymonk.com/learning/books/1/chapters/7-classes/lessons/40-building-your-own-class

What is the difference between a local and an instance variable?

A local variable is only available inside the method where it is defined.




An instance variable is bound to a specific class, making itself available for every method in that class.




Source: https://rubymonk.com/learning/books/4-ruby-primer-ascent/chapters/45-more-classes/lessons/110-instance-variables

What is a getter method? What can be used as a subsitute?




Hint: give an example using a theoretical class "Item" and an instance variable "description"

A method who's sole purpose is to return the value of that particular instance variable.




Example:




class Item




def initialize(description)


@description = description


end




def description


@description


end




end




Substitute:




attr_reader :description




under class definition, and replaces bolded section in above example code




Source: https://rubymonk.com/learning/books/4-ruby-primer-ascent/chapters/45-more-classes/lessons/110-instance-variables

What is a setter method? What can be used as a substitute?




Hint: give an example using a theoretical class "Item" and an instance variable "description"

A method that allows an instance variable to be changed from the outside.




Example:


class Item


def initialize(description)


@description = description


end




def description=(new_description)


@description = new_description


end




def description


@description


end




end






Substitute:




attr_writer :description




under class definition, and replaces bolded section in example code




Source: https://rubymonk.com/learning/books/4-ruby-primer-ascent/chapters/45-more-classes/lessons/110-instance-variables