What is the Notation used for denoting class variables in Ruby?

Answer

1) a constant begins with an uppercase letter and it should not be defined inside a method

2) a local must begin with a lowercase letter or the _ underscore sign

3) a global begins with the $ sign; an uninitialized global has the value of "nil" and also produces a warning. can be reffered anywhere in the program

4) instances begin with the @ sign; an uninitialized instance has the value of "nil" and also produces a warning

5) a class variable begins with double @@ and have to be first initialized before being used in a method definition, otherwise you will get an error if you refer to it without initializin

 

All ruby Questions

Ask your interview questions on ruby

Write Your comment or Questions if you want the answers on ruby from ruby Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---