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

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!