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 and their Methods Struct Methods

Roderick Royce
Roderick Royce
1,236 Points

How do I concatenate the struct, init, and func within their methods of Doubles?

struct Expense { var description: String var amount: Double = 0.0 var percentage: Double

init (percentage: Double) {
    self.percentage = Double

func calculateTaxes(percentage: Double) -> Double {
    }
}

}

//here is what I have so far but I can't think of the shortCut language to keep the strings or doubles connected. Thank you for all of your help because there are 4 challenges on this part and this is just 1 of the 4.

struct.swift
struct Expense {
    var description: String
    var amount: Double = 0.0
    var percentage: Double

    init (description: String) {
        self.description = description
        self.percentage = Double
    }

  func calculateTaxes() -> Double {

    // add the calculateTaxes method here
    // it should accept only one parameter named 'percentage' of type Double
}
}

Hello. Its asking you to name det parameter "Percentage". So it will be "func calculateTaxes (percentage: Double) {}. Do not return a Double. (-> Double). Hope you understand