/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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