-
Notifications
You must be signed in to change notification settings - Fork 1k
Rewrote named arguments tour #728
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
Conversation
|
||
printName("John","Smith") // Prints "John Smith" | ||
printName(first = "John",last = "Smith") // Prints "John Smith" | ||
printName(last = "Smith",first = "John") // Prints "John Smith" |
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.
style: space after ,
prerequisite-knowledge: function-syntax | ||
--- | ||
|
||
When calling methods, you can use the name of the parameters explicitly in the call, like so: |
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.
maybe provide
instead of use
?
println(first + " " + last) | ||
} | ||
|
||
printName(last="Smith", "john") // Does not compile |
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.
spaces left and right of =
, uppercase John
.
When calling methods, you can use the name of the parameters explicitly in the call, like so: | ||
|
||
```tut | ||
def printName(first: String, last: String) = { |
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.
Unit
-valued functions should have an explicit return type (also below)
println(first + " " + last) | ||
} | ||
|
||
printName(last = "Jones") |
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 guess you removed this example because it's in on a different page now?
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.
Exactly
b9b9731
to
66f52fe
Compare
@heathermiller ready to merge |
No description provided.