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 trialWelby Obeng
20,340 PointsI don't understand this task
Pasan Premaratne I don't understand this task
You said to create a failable initializer that accepts a dictionary as input an initializes all the stored properties. How can I do that if all the properties are constants? Am I missing something
struct Book {
let title: String
let author: String
let price: String?
let pubDate: String?
}
4 Answers
Michael Hulet
47,913 PointsA constant's value doesn't change once it's initialized. In other words, it's legal to do something like this:
class Example{
let constant: String
init(value: String){
self.constant = value
}
}
TeamTreeHouse ✔
1,128 PointsCreate a constant named favDessert and assign to it a string containing your favorite dessert. Remember the syntax for a string is some text enclosed with two double quotes. Pro Tip: Dessert is spelled with two s'
Jason Hess
4,789 Pointsso I'm new to swift and trying to pass this challenge, here's my code:
let = "favDessert";
var str = "cookies";
Do I ned to include the semi-colons?
I've also tried this syntax, what am I doing wrong here.
let str = "favDessert"
let str = "cookies"
Any help would be great. Thanks in advance
ios1alamin
4,310 PointsHere is the correct answer: let favDessert = "Candy" (Note: You can use anything instead of "Candy")
stephenallison
8,559 Pointslet favoriteDessert = "input fav here" is the proper syntax. The question itself can be tricky.