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 trialAndrew Cota
747 Pointsit keeps saying that my " 'let' declarations require an initializer expression" does anybody know what this means?
Please read above
let title: String
println("A Dance with Dragons")
Andrew Cota
747 Pointsthank you so very much!
Andrew Cota
747 Pointsthank you so very much!
Andrew Cota
747 Pointsthank you so very much!
3 Answers
agreatdaytocode
24,757 Pointslet title: String
title = "A Dance with Dragons"
println(title)
Robin Nilsson
3,783 PointsOr rather:
let title: String = "A Dance with Dragons"
println(title)
agreatdaytocode
24,757 PointsThat will work too. :)
kjvswift93
13,515 PointsSince you declared 'title' as a constant, meaning a value fixed in memory, it must be given a value, else the concept of a constant declaration has no meaning. The error is basically Swift saying, "Why did you tell me to store a constant value in my memory without telling me what it is?"
Andrew Cota
747 Pointsthank you so very much
boruch woolstone
1,192 Pointswhat you have done above is declared a constant (using the "let" keyword) given it a name (title) and said that it is of the type String but you have not given it any value. if you wrote let title: String = "A String" then the compiler would not show that error message and the value of title would be A string
Andrew Cota
747 PointsI appreciate your support on this question!
Andrew Cota
747 PointsAndrew Cota
747 Pointsthank you so very much!