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 Inheritance Inheritance and Initializers

What is an expected declaration?

var tshirt = Clothing(title: "Vintage", price: 49.99, designer: "Prada")
tshirt.title
tshirt.price
tshirt.discountedPrice(50)
tshirt.size

1 Answer

The error message "expected declaration" simply means that there exists a value that has not been either initialized nor declared with the keywords let or var. For example, if I were to type the following in a playground, the error message would say something along the lines of "expected declaration".

myVariable = 42

It would be corrected by 'declaring' myVariable as either a variable or a constant like this:

var myVariable = 42