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 Swift Enums and Structs Structs Stored Properties

Josh Smith
Josh Smith
1,049 Points

Where is this wrong?

I think this is very close to right? But i'm not sure where I'm wrong though?

struct.swift
struct Expense {
    var description: String
    var amount: Double
}

var travel = Expense(description: "Flight to Cupertino", amount: "500.00")
travel.Description
travel.Amount

1 Answer

Neil Docherty
Neil Docherty
10,418 Points

The amount variable is set as a double, you therefore don't need the quotation marks.

struct Expense {
    var description: String
    var amount: Double
}

var travel = Expense(description: "Flight to Cupertino", amount: 500.00)
Josh Smith
Josh Smith
1,049 Points

Damn it.. so close. Thnks Neil :)

Neil Docherty
Neil Docherty
10,418 Points

No worries. Took me a good bit of staring at to realise.

Remember - use the Code Challenge preview when you get something wrong as it give you an idea of where to look at for the problem.

Josh Smith
Josh Smith
1,049 Points

Hey Neil - yeah I usually do click on the preview button but I kind of find it doesn't really help me that much. I'm still really green to iOS dev stumbling my way through lol!