-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Splat tuple union #223
Comments
For now I think I'll make the compiler say an error when splatting over a union of tuples (instead of silently failing). It's a valid use case, but I wonder what was your original use case. If |
I think that was while toying with a macro generated Enumerator. I don't really mind if |
Yes, your code should work, it's just that it's not trivial to implement because our dispatch algorithm doesn't consider different splats yet. I'll start with erroring in this case and later try to implement it. |
Both of these won't compile on both class Foo
def initialize(*args)
@args = args
end
def a
args = @args
b(*args)
end
def b(*args)
b(args)
end
def b(args : Enumerable(String))
pp args
end
end
Foo.new("Foo").a
Foo.new("Foo", "Bar").a Error
|
Can be rewritten to: t = rand > 0.5 ? {"Foo"} : {"Bar", "Baz"}
def f(*t)
pp t
end
f *t Giving:
|
Bump 👍 This still won't compile on master |
Given
With
we get
instead of
With
we get
This is inconsistent at least, but I'd also expect either variant to work.
The text was updated successfully, but these errors were encountered: