Return to Snippet

Revision: 5322
at February 28, 2008 04:04 by zippoter


Initial Code
class App
    $super_count = 111
    @@count = 0
    
    def initialize (caller)
       @call = caller
    end

    # instance method
    def callme
        p “called using #{@call}”
        @@count+=1
    end

    # class method
    def App.callmetoo
        p “called using callmetoo”
        @@count+=1
    end

end

obj1 = App.new(”OBJECT1″)
obj2 = App.new(”OBJECT2″)
p obj1.callme
p obj2.callme
p App.callmetoo
p $super_count #can be access outside the class
#p [email protected]@count #cant access outside the class

Initial URL


Initial Description


Initial Title
instance variable vs class variable

Initial Tags


Initial Language
Ruby