/ Published in: Ruby
Expand |
Embed | Plain Text
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 App.@@count #cant access outside the class
You need to login to post a comment.
