fork download
  1. class A
  2. FOOBAR = 42
  3. end
  4.  
  5. class B < A
  6. class << self
  7. def case_1
  8. FOOBAR # <<< how to fix this?
  9. end
  10.  
  11. def case_2
  12. self::FOOBAR # <<< is this the proper way of doing it? / what does that do exactly?
  13. end
  14. end
  15.  
  16. def case_3
  17. FOOBAR # cool
  18. end
  19.  
  20. def self.case_4
  21. FOOBAR # cool
  22. end
  23. end
  24.  
  25. # puts B.case_1 # => uninitialized constant Class::FOOBAR (NameError)
  26.  
  27. puts B.case_2
  28. puts B.new.case_3
  29. puts B.case_4
Success #stdin #stdout 0.01s 7412KB
stdin
Standard input is empty
stdout
42
42
42