Ruby Developer Question:

Download Job Interview Questions and Answers PDF

As you know ruby provides four types of variables. List them and provide a brief explanation for each?

Ruby Developer Interview Question
Ruby Developer Interview Question

Answer:

The 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.

Download Ruby Developer Interview Questions And Answers PDF

Previous QuestionNext Question
What is the Notation used for denoting class variables in Ruby?Please explain what is MVC and why do we use it?