As you know ruby provides four types of variables. List them and provide a brief explanation for each?
Submitted by: MuhammadThe four types of variables in Ruby are as follows:
☛ Global variables begin with $ and are accessible from anywhere within the Ruby program regardless of where they are declared-it stands to reason that they must be handled with care.
☛ Local variables begin with a lowercase letter or an underscore. The scope of a local variable is confined to the code construct within which it is declared.
☛ Class variables begin with @@ and are shared by all instances of the class that it is defined in.
☛ Instance variables begin with @ and are similar to class variables except that they are local to a single instance of a class in which they are instantiated.
Submitted by: Muhammad
☛ Global variables begin with $ and are accessible from anywhere within the Ruby program regardless of where they are declared-it stands to reason that they must be handled with care.
☛ Local variables begin with a lowercase letter or an underscore. The scope of a local variable is confined to the code construct within which it is declared.
☛ Class variables begin with @@ and are shared by all instances of the class that it is defined in.
☛ Instance variables begin with @ and are similar to class variables except that they are local to a single instance of a class in which they are instantiated.
Submitted by: Muhammad
Read Online Ruby Developer Job Interview Questions And Answers
Top Ruby Developer Questions
☺ | Tell us what is class libraries in Ruby? |
☺ | Tell me can you call a private method outside a Ruby class using its object? |
☺ | Explain me what is the function of ORM in Ruby on Rails? |
☺ | Tell me the role of modules and mixins in Ruby? |
☺ | What is the difference extend and include? |
Top Web Developer Categories
☺ | Bootstrap Interview Questions. |
☺ | Front End Web Developer Interview Questions. |
☺ | Typography Interview Questions. |
☺ | Laravel PHP Developer Interview Questions. |
☺ | Junior Developer PHP Interview Questions. |