Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Enums and Structs Structs Stored Properties

Enums and structs step 2 of 2.. I'm having trouble with the answer..

i did var travel = Expense.description = "" and i dont think i can also do var tavel = Expense.amount = 500.00

I'm kind of stuck..

struct Expense {
  var description: String
  var amount: Double


var travel = Expense.description = "Flight to Cupertino"

1 Answer

Jhoan Arango
Jhoan Arango
14,543 Points

Hello Devin:

From what I can see, what you are trying to do is create an instance of “Expense”.

struct Expense {
    var description: String // String type
    var amount: Double // Double type    

// Instance 

var travel = Expense(description: "Flight to Cupertino", amount: 250.00)

When creating an instance of a class or struct you have to call it by its name and its parameters. Since structs create their own initializers, you do not have to create one, just simple use its store properties as its parameters, and give them values according to their type.

Hope this helps