Advertisement
Guest User

Untitled

a guest
Aug 18th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.34 KB | None | 0 0
  1. class Foo
  2.   # Write the instance variable foo into the class Foo
  3.   @@foo = 14
  4.  
  5.   x = Foo.new
  6.  
  7.   def x.foo
  8.     # Reads the instance variable foo from the class of Self, which is Foo
  9.     puts @@foo
  10.   end
  11.  
  12.   x.foo
  13.  
  14.   def self.foo
  15.     # Reads the instance variable foo from self
  16.     puts @@foo
  17.   end
  18.  
  19.   self.foo
  20. end
  21.  
  22. puts Foo.foo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement