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 trial
Tatenda Madzokere
2,970 PointsInstances of classes .idont know where to go from here please help
class Shape { var numberOfSides : int let someShape
}
init(shape: someShape) { self.someShape = (int)
3 Answers
Tatenda Madzokere
2,970 PointsObject-Oriented Swift 3 Challenge Task 1 of 1
Let's get in some practice creating a class. Declare a class named Shape with a variable property named numberOfSides of type Int.
Remember that with classes you are required to write an initializer method.
Once you have a class definition, create an instance and assign it to a constant named someShape.
Thats the question
Jeff McDivitt
23,970 Pointsclass Shape {
var numberOfSides: Int
init(numberOfSides: Int) {
self.numberOfSides = numberOfSides
}
}
let someShape = Shape(numberOfSides: 3)
Tatenda Madzokere
2,970 PointsThanx Jeff
Jeff McDivitt
23,970 PointsJeff McDivitt
23,970 PointsIs this for a code challenge if so ask the question on the challenge so I can pull it up and assist you