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.

Miguel Leon
1,720 PointsWhat is a Boolean ?
I already finished swift basics but i still can't quite understand the function of a boolean.
2 Answers

Jhoan Arango
13,603 PointsThe concept of a bool is pretty simple, think of it as a condition that is true or false.
For example.
/*
Are you human ? There are two posible answers to the question ( true or false )
therefore this can be consider a boolean. Lets see it in code.
*/
var human = true
if human == true {
println("Yes this is true")
} else {
println("No this is false")
}
// This will print “Yes this is true” because the variable human
// was declared with the value "true"
/*
You can read that as If human is true, then print “Yes this is true”, if it’s false, print “No this is false” So the condition of something being true or false is a boolean. It only has those two answers.
Hope you understand.

Austin Liu
3,326 PointsA boolean is a value that either responds in 'true' or 'false', or in simpler terms, 'yes' or 'no'. Booleans can be used in asking if, suppose if a user is connected to the internet, or if they like cheese, or something along those lines. Hope this helped!
David Richardson
10,213 PointsDavid Richardson
10,213 PointsBoolean is a data type that only has 2 possible values, either true or false (1 or 0)