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 Basics (retired) Variables and Constants Constants

John Moron
John Moron
1,658 Points

how do you do you create a contect language and assign it string "swift"

How having trouble completing the content language challenge for ios i tried everything but cant figure out how to do it i tryed the way the video told me how but still cant figure it out

constants.swift
let randomConstant = "Random Text"

Can you post the line of code you tried submitting in the challenge here? I'll see where your error's occurring.

John Moron
John Moron
1,658 Points

That's what i put.

3 Answers

So you can either declare an object as a constant or a variable. If I wanted to declare a variable named randomVariable and assign it the string "Random Text" I would do so like this:

var randomVariable = "Random Text"

var denotes that randomString will be a variable whose value can be reassigned. let on the other hand denotes that something will be a constant whose value can only be assigned once, like this:

let randomConstant = "Random Text"
John Moron
John Moron
1,658 Points

ohh omg that's what i was supposed for do for let thanks for your help man.

John Moron
John Moron
1,658 Points

I tried this but i wont work