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

Viewed 3780

I have a module with a class variable in it

module Abc
  @@variable = "huhu"

  def self.get_variable
    @@variable
  end

  class Hello
    def hola
      puts Abc.get_variable
    end
  end
end

a = Abc::Hello.new
a.hola

Is it possible to get @@variable inside Hello without using get_variable method? I mean something like Abc.variable would be nice. Just curious.

2 Answers
Related