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 Swift Operators Assignment and Comparison

Al Hughes
seal-mask
.a{fill-rule:evenodd;}techdegree
Al Hughes
iOS Development with Swift Techdegree Student 533 Points

Usage of "=="

Hello everyone,

As I am making my way through these courses I am trying to make sense of how these practices would be used in a coding scenario. I am assuming this is not used to check something in the code itself as you could look at two values and see of the are equal to each other. Would this be something that would be useful in the following example?

user is setting up and account and needs to input a password twice.

would this compare the two values and return an error if the passwords don't match?

Harsh Pareek
Harsh Pareek
Courses Plus Student 489 Points

if you use it with a proper string comparison function then it will give an error, if the password doesn't match.

1 Answer

You had it right the first part. “==“ is a comparison operator. It checks if the value on both sides is equal. More info can be found in the Apple Documentation Just jump down to the comparison section and read that.