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 trialswilllsea
4,957 PointsMy code here seems (to my eyes) to be correct. What am I missing?
I can't figure this one out.
class Button {
var width: Double
var height: Double
init(width:Double, height:Double){
self.width = width
self.height = height
}
func incrementBy(points: Double){
width += points
height += points
}
}
class RoundButton: Button {
var cornerRadius: Double = 5.0
override func incrementBy(points: Double = 7.0){
width += points
height += points
}
}
2 Answers
William Li
Courses Plus Student 26,868 PointsThe argument passing is missing the little _ underscore, other than that, your code is fine
override func incrementBy(_ points: Double = 7.0){
width += points
height += points
}
swilllsea
4,957 PointsThank you William. Do you know why Xcode 7.0 beta 4 doesn't seem to like having an underscore there? It's telling me that percentage has no keyword name, making the _ extraneous.
William Li
Courses Plus Student 26,868 PointsHi, S Willsea, I'm only using final release of Xcode on my machine, but given how young Swift is and Apple has been actively pushing breaking changes to the language, I wouldn't be surprised if that's the case.
swilllsea
4,957 PointsVery good, thank you William.
Josue Gisber
Courses Plus Student 9,332 PointsIts because Xcode 7.0 use other version of swift. You should use final release of Xcode 6.4 because that
s the one that works with the version of swift teach at the corse.
swilllsea
4,957 Pointsswilllsea
4,957 PointsNever mind, I realized that as I was following along, my version of Xcode for some reason rejects the necessity of the " _ " inserted in the override function.