-
-
Notifications
You must be signed in to change notification settings - Fork 670
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
[std] improve haxe.Rest docs and mention ... syntax #10010
Conversation
Should be used as a type for the last argument of a method, representing that | ||
arbitrary number of arguments of given type can be passed to that method. | ||
```haxe | ||
function f(...rest:Int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it just me or using element type like :Int
here feels weird?..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean, that's the whole point of the ...
syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure, i think every language i saw so far use the array type for the actual rest arg local var. as i said, maybe it's just a habit, but to me this reads like rest is an Int
, but it's actually not, I don't know...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, at least Java and Kotlin do it like this. I hadn't ever really noticed that TS and C# do it differently, probably because I use varargs so rarely...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh well ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't understand why we support ...
in function definition, function f(...rest:Int) {}
isn't clear at all imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not too late to cut it out :)
To me it looks consistent with allowing call(...collection)
at call site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kotlin seems even weirder in that regard (fun f(vararg rest:Int)
and then f(*args)
) :)
No description provided.