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

iOS Object-Oriented Swift 2.0 Classes Instances of Classes

William Liu
William Liu
1,516 Points

Can someone give me the solution to Task 1, please?

I simply can't figure out what I need to add or change in order to finish this task. Thank's in advance!

// Enter your code below
class Shape {
var numberOfSides: Int 
init(numberOfSides: Int){
self.numberOfSides = numberOfSides
let someShape = Shape()

2 Answers

Close, but you need to tell your shape how many sides it has by passing it numberOfSides:X where X is the number of sides - for example to create a 4 sided shape...

let someShape = Shape(numberOfSides:4)
William Liu
William Liu
1,516 Points

Thanks a lot, Gavin! :)

I guess I didn't know what to enter for X in (numberOfSides:X) since the task doesn't specify...

No problem. If you're happy with the answer you can mark it as correct. :) The task could've been clearer - e.g. asking you to create a square. :)