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 trial

iOS Swift 2.0 Basics An Introduction to Swift Programming Working With Variables

Declare 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.

variables.swift
var str = "swift"
str = "Language"
str = "language"

2 Answers

What 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".

Thank you man, i was having the hardest time lol. really, thanks

var str = "language" var language = "Swift"