-
-
Save anonymous/62ecd1b4b7657503d0f418a9ed04f603 to your computer and use it in GitHub Desktop.
A confusing behaviour involving passing a tuple to a constructor without parentheses.
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
# Simple working example shown below | |
foo = Foo.new({2, 2}) | |
# ^ ^ Outer parentheses present | |
class Foo | |
def initialize(bar : {Int32, Int32}) | |
# Code | |
end | |
end | |
# This, however, will not compile: | |
foo = Foo.new {2, 2} | |
# ^ ^ Outer parentheses removed | |
class Foo | |
def initialize(bar : {Int32, Int32}) | |
# Code | |
end | |
end | |
# When run, this results in | |
# unexpected token: , | |
# foo = Foo.new { 2, 2 } | |
# ^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment