Types of Variables and their Usage
Get to know various kinds of variables in Ruby. Moreover, learn how and when to use them.
Definition and Usage
Naming | Scope | Initialization | |
---|---|---|---|
Global Variables | Global variables start with a $ sign. |
Their scope is global which means that they can be accessed from anywhere in a program. | There’s no need to initilize. Uninitialized global variables have the value nil . |
Local Variables | Local variables begin with a |
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy