Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.32 KB | None | 0 0
  1. class Stuff
  2.   def initialize
  3.     @blah = ""
  4.   end
  5.  
  6.   def blah
  7.     @blah
  8.   end
  9. end
  10.  
  11. s = Stuff.new
  12.  
  13. s.blah << "things"
  14. s.blah #returns "things" - the instance variable was changed
  15.  
  16. s.blah = "stuff" #returns error - if s.blah is really a reference to @blah, which is a String object, why can't I use the = method?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement