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

Aidan Bartlett
Aidan Bartlett
643 Points

If you have an implicit variable, how do you know it's been assigned correctly?

E.g. if I did:

var str = "Something"

How do I know it has been assigned the correct variable String?

1 Answer

It looks from your question that you are in a playground. Below that line, print the value of (str) by replacing your code with the following:

var str = "Something"
println(str)

Println() is a function that can print many different types of data from ints to strings. When developing advanced applications, developers will use the println() function to make sure that values are what they need to be and also to monitor values throughout the process of the application.

If for any reason you want to check the raw value and you are in a playground, just type the variable or constant name to view the current value.

var str = "Something"
str 

Typing (str) after declaring (str) Should show the value of (str) in the side panel.

If you have any more questions, feel free to ask!