Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTimo Koko
1,758 PointsChallenge compiler keeps returning the same error while the code is properly written according to Xcode
I have received the following error while the code works properly in my Xcode, I would not really know what they mean with this compiler error but it works properly in my Xcode version. Override, method signatures are correct. What would the problem be?
The compiler error (from the challenge): swift_lint.swift:21:17: error: argument names for method 'incrementBy(points:)' do not match those of overridden method 'incrementBy' override func incrementBy(points: Double = 7.0) ^ _
1 Answer
Marina Alenskaja
9,320 PointsHi!
This one is a bit tricky.. But you need to add the _ before the points argument in your method. This is due to the fact that you specify a default value in the method. So when using the method, the parentheses in it don't need to be filled - it will just use the default value. I hope that makes sense.. Like this:
class RoundButton: Button {
var cornerRadius: Double = 5.0
override func incrementBy(_ points: Double = 7.0){
width += points
height += points
}
}
He actually talks about this in the video at 4:30 - and explains.
Timo Koko
1,758 PointsTimo Koko
1,758 PointsAh, thank you! I've re-watched the video, really helped me with understanding.