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) Control Flow For-Condition-Increment

What is the difference between identical(===) and equal(==)?

Any and all help appreciated!

Logan R
Logan R
22,989 Points

Noemi Totos You should post that as an answer, not a comment :)

2 Answers

Noemi Totos
Noemi Totos
12,601 Points

Hi Aysha, I had hard time with this myself until I fully understood what is about... Identical has to be identical (exactly the same), for ex. 3===3 or "3"==="3" (as a string) would evaluate as true, but "3" is not identical with 3, because one is a string, one is a number. Equal is way more forgiving, meaning "3" == 3 would evaluate true, however one is a string (in between quotes) and the other is a number. I hope this helped!

If they are identical they will be the same data type whereas with equal the data type doesn't make much of a difference.

I hope this helped you out! If you have any more questions feel free to ask!

-Luke