Last active
December 15, 2015 17:49
-
-
Save budnik/5299510 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Acme | |
attr_accessor :a, :b | |
def initialize | |
@a=[] | |
@b=[] | |
end | |
def foo! | |
a<<5 | |
self | |
end | |
def bar! | |
b=[5] | |
self | |
end | |
end | |
a = Acme.new | |
a.foo!.bar! | |
puts a.a, a.b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo | |
Bar||=5 | |
puts 5 | |
end | |
def bar | |
puts(a) if (a = 5) | |
end | |
def baz | |
if a = 5 | |
puts a | |
end | |
end | |
def qux | |
if (a,b = [1,5]) | |
puts a | |
end | |
end | |
foo or bar or baz or qux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
more gotchas on http://en.wikipedia.org/wiki/Gotcha_(programming)