ruby oriented Flashcards
class
Tell Ruby to make a new type of thing.
object
Two meanings: the most basic type of thing, and any instance of some thing.
instance
What you get when you tell Ruby to create a class.
def
How you define a function inside a class.
@
Inside the functions in a class, self is a variable for the instance/object being accessed.
inheritance
The concept that one class can inherit traits from another class, much like you and your parents.
attribute
The concept that a class can be composed of other classes as parts, much like how a car has wheels.
is-a
A phrase to say that something inherits from another, as in a “salmon” is-a “fish.”
has-a
A phrase to say that something is composed of other things or has a trait, as n “a salmon has-a mouth.”
class X(Y)
Make a class name X that is-a Y.
class X(object): def intialize(j)
class X has-a initialize that takes a J parameter
class X(object): def M(self, j)
class X has-a function named M that takes a j parameter
foo = X()
set foo to an instance of class x
foo.M(J)
From foo get the M function, and call it with parameter j
foo.K = Q
from foo get the K attribute and set it to Q