The keyword "self" in Ruby always refers to the current object within that context. Self can be referenced to a class as well as an instance
Scope refers to the level of accessibility our variables have. Allowing our program to have different levels of scope allow certain variables to be accessed or referenced at different times. 3 types of scope would be local, instance, and class
Local
Refers to a variable that is declared within a method and cannot be accessed outside of said method
Class
Refers to variables that are accessed within all instances of our class. An easy way to detect a class variable is by the "@@" character next to our variable
Instance
Instance variables values are only used within specific instances of an object. Similar to our class variable we use a single "@" in order to declare our instance variable
Top comments (0)