Skip to content

Instantly share code, notes, and snippets.

@phoet
Created April 20, 2011 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phoet/931361 to your computer and use it in GitHub Desktop.
Save phoet/931361 to your computer and use it in GitHub Desktop.
<< vs. += execution in different context
class StrangeOperatorBehavior
def doit
some_array << [3,4] # ok
some_array += [6,7] # nil
end
def some_array
@some_array ||= []
end
end
puts StrangeOperatorBehavior.new.doit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment