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 trialBob Kim
Courses Plus Student 765 PointsExpense.description
I don't know how to pass this one. If you guys could help me that would be great.
struct Expense {
var description: String
var amount: Double = 0.0
init (description: String, amount: Double) {
self.description = "Macbook"
self.amount = 100
}
func calculateTaxes (percentage: Double) -> Double {
return (self.amount * (percentage/100))
}
}
var item = Expense.description
1 Answer
John Wilson
12,845 PointsWhen creating your var 'item' you must specify the same parameters as in your initializer. In this case, 'description' or it won't work. This completes the 'instance' properly. Then set your amount = 100 as done below:
var item = Expense(description: "enter anything here") item.amount = 100
John Wilson
12,845 PointsJohn Wilson
12,845 Pointssorry
item.amount = 100 should be on the next line below!