0

The question says it all. For example:

class Foo
  INSTANCE = new

  def initialize
    p "initialized"
  end
end

Will print only when Foo::INSTANCE accessed, not automatically after compilation.

Is it expected behavior?

ClassyPimp
  • 715
  • 7
  • 20

1 Answers1

2

Right now, if you don't use a constant it's not even type checked. So constants are only executed if you use them. This might change in the future.

asterite
  • 2,906
  • 1
  • 14
  • 14