Created
July 28, 2018 14:50
-
-
Save kevinhughes27/1e842fb16dac0e4e772f397500064905 to your computer and use it in GitHub Desktop.
A trailing comma in a list of attr_reader hijacks the next method definition. How is this not a syntax error?
This file contains 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 Wat | |
def initialize(thing) | |
@thing = thing | |
@foo = 'foo' | |
end | |
# this ends up creating an attr_reader for foo | |
# but shouldn't it throw an error when it | |
# sees `def` after a comma? | |
attr_reader :thing, | |
def foo | |
'bar' | |
end | |
end | |
wat = Wat.new('thing') | |
puts wat.thing | |
#-> thing | |
puts wat.foo | |
# -> foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment