Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics Swift Types Numbers and Booleans

I haven't comprehended the Bool usage in coding. What do they do?Why do we even use true or false?

Are the Booleans an argument apart or they're used for numbers?

eberhapa
eberhapa
51,495 Points

I asked myself the same question when i started coding. I think you will understand the usage trough time. I use booleans for checking e.g. if somebody is logged in. In this case you create a variable called isLoggedin and set it to true or false. The short syntax of checking if the variable is true or false is "if isLoggedIn {}". You don't have to write "if isLoggedIn == true {}". You will come over more examples if you continue with Pasans courses.

Wow i just finished the exercises after this video and realise it's a really simple concept... Thank you for the example!