Access a module's class variables inside a class in Ruby Access a module's class variables inside a class in Ruby ruby ruby

Access a module's class variables inside a class in Ruby


You cannot access @@variable directly (i.e., Abc.variable) within the scope of the Hello class in the module Abc. Why? Because, when the Ruby interpreter sees something like Abc.variable, it would think variable as class/module method of Abc.

It is important to think the Ruby way when programming in Ruby.


try this

Abc.class_variable_get(:variable)