Ruby - Explain the use of global variable $ in Ruby

Explain the use of global variable $ in Ruby

The global variable is declared with $ prepended. It has full scope in the application. These variables can be used anywhere within an application.

For Example:
$departmentName = “Operations”
Proper care is to be taken when using global variables, as they can also be changed from anywhere within the application, which leads to bug tracking later. This process can make the bug tracking more difficult.

Explain the use of global variable $ in Ruby

If you declare one variable as global we can access any where, where as class variable visibility only in the class
Ruby - Difference between nil and false in ruby
False is a boolean datatype, Nil is not a data type........
20 Python Interview Questions and Answers - Freshers, Experienced
Python interview questions - What is Python? State some programming language features of Python, Explain how python is interpreted, What are the rules for local and global variables in Python?
What is Python? State some programming language features of Python.
What is Python? - Python is a modern powerful interpreted language with objects, modules, threads, exceptions, and automatic memory managements......
Post your comment