Ruby - Constants in Class

Introduction

You can access constants declared inside a class.

The constants are identifiers beginning with a capital letter.

To access the constant A, you would need to use the special scope resolution operator :: like this:

Demo

class X 
  A = 10 # from   w  ww .  j  a va 2s . co m
                        
  class Y       
  end  
  
end 

X::A

Related Topic