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 trialdajahn carter
Courses Plus Student 97 PointsDeclare a variable named language and assign the string "Swift".
Declare a variable named language and assign the string "Swift". We didn't go over the specific syntax for creating a String so remember to start with a double quote, write the word, and close it with a double quote.
var str = "swift"
str = "Language"
str = "language"
2 Answers
warp42
3,171 PointsWhat you're looking for is
var language = "Swift"
Swift infers that it is a string automatically because you put Swift in "".
You could also write the code below, if you wanted to explicitly declare the type as a string, but that is unnecessary.
var language = String("Swift")
What you did was declare variable str as "swift", and then you changed str to be "Language" and then "language".
ios1alamin
4,310 Pointsvar str = "language" var language = "Swift"
dajahn carter
Courses Plus Student 97 Pointsdajahn carter
Courses Plus Student 97 PointsThank you man, i was having the hardest time lol. really, thanks