I’ve completed the Windowing System exercise on the Swift track and found that my local Swift testing (Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4) appears to require function argument labels and parameter names, but the test suite on the Exercism doesn’t.
Apple’s documentation says “By default, parameters use their parameter name as their argument label.”, so I’m not exactly sure what’s going on with this behavior.
As an example, this is the code that passes the test on the site:
struct Position {
var x = 0
var y = 0
mutating func moveTo(newX: Int, newY: Int) { // <- no names here
x = newX
y = newY
}
}
However, this fails on my local machine with “error: missing argument labels ‘newX:newY:’ in pos.moveTo(newX, newY)”
If I change the code to this on my local machine, it passes (note the underscore argument labels on the mutating func
line)
struct Position {
var x = 0
var y = 0
mutating func moveTo(_ newX: Int, _ newY: Int) {
x = newX
y = newY
}
}
Is this expected? Is it a version difference? Is there some configuration setting that affects this? Just curious why my local environment behaves differently from the Exercism testing environment.
Thanks.