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 trialEmma Rosenthal
2,412 PointsAdd a method to the Expense struct that will calculate taxes based on a percentage passed to the method
I have no idea what I am doing wrong. Somebody please help me.
struct Expense {
var description: String
var amount: Double = 0.0
init (description: String) {
self.description = description
{
func calculateTexas(percentage: Double) {
}
}
4 Answers
Steve Hunter
57,712 PointsSomething like:
struct Expense {
var description: String
var amount: Double = 0.0
init (description: String) {
self.description = description
}
func calculateTaxes(percentage: Double) {
}
}
Kevin Franks
12,933 PointsCheck you Brackets. The close bracket for your init function is an open bracket vs. close.
Steve Hunter
57,712 PointsI think you're pretty much there. Two things, though. One was mentioned by Kevin above; your braces aren't quite right.
Second, as just because the first part of the challenge requires nothing inside the method, is the spelling. You're calculating Taxes
not Texas
. ;-)
I think if you fix those two things, you'll get to the next stage. If not; just shout and we'll come and help.
Steve.
Emma Rosenthal
2,412 PointsWhat should the brackets be instead of what I have?
Kevin Franks
12,933 PointsChange from { to } right above your function call.
kjvswift93
13,515 PointsIn the first challenge the function does not return anything, so it should be:
func calculateTaxes(percentage: Double) () {
}
Steve Hunter
57,712 PointsHi Kevin,
I don't think the ()
are needed as omitting the return arrow and type is sufficient to show the function isn't returning anything.
I think. I'm no expert.
Steve.
Kevin Franks
12,933 PointsKyle not Kevin though you are correct.
Steve Hunter
57,712 PointsSorry!! :-)
Emma Rosenthal
2,412 PointsEmma Rosenthal
2,412 PointsThank you Steve and Kevin!