Why the warning, charlie brown?

charlie = Class.new do
?> def initialize

@@brown = "#802A2A"

end
end
=> #Class:0x00000002a8b838

charlie.new
(irb):8: warning: class variable access from toplevel
=> #<#Class:0x00000002a8b838:0x00000002a85528>

On 12/20/2011 10:21 AM, Intransition wrote:

Scoping, apparently…

class Outer
@@brown = “Outer’s var”
charlie = Class.new do
def initialize
p @@brown
end
end
charlie.new # ==> “Outer’s var”
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs