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 trialThomas Katalenas
11,033 Pointshaving trouble here!?!?!self me self me self me
struct myExpense {
48. let des: String
49. let amou: Double
50. init(des: String, amou: Double){
51. self.des = des
52. self.amou = 0.0
53. }
54. }
so the question mentions storing two properties so I guess my answer still compiles but didn't meet the specifications of the parameters. maybe you can give me a hint ? I might be able to answer it myself.
struct Expense {
let description = String
let amount = Double
init(description: String, amount:Double){
self.description = description
self.amount = 0.0
}
2 Answers
Keli'i Martin
8,227 PointsSo you're on the right track. There is one change you'll want to make in your intializer. Then you need to actually declare an Expense variable outside of the struct and use the initializer to populate the initial values from the challenge.
Hope this helps!
Reed Carson
8,306 PointsA general tip: it will help you IMMENSELY if you don't use shorthand for naming variables or objects of any kind. I did that at first and it may be easier at the time but when you have to go back and look at your code later it can be impossible to decipher what you meant. Even more so if its a project someone else will have to work on as well.
It will be a big help to name everything clearly even if it means more typing, but that shouldn't be a problem anyway because after you've declared something, autocomplete will finish typing it for you elsewhere.
Keli'i Martin
8,227 PointsKeli'i Martin
8,227 PointsIn fact, you probably don't even need an initalizer to get this working.
Keli'i Martin
8,227 PointsKeli'i Martin
8,227 PointsYes, I just confirmed, the initializer is not necessary to pass this challenge
Thomas Katalenas
11,033 PointsThomas Katalenas
11,033 Pointsthats creative, I like it!! here's the beginning of the journey
lets change it to