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 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