user6912219 user6912219 - 2 months ago 6
Swift Question

Bool in swift - playgrounds

I'm Learning swift using playgrounds. Can I declare a bool and have it be only true or false so I can use it as a condition for a function?

Answer
You can declare a Boolean variable using "Bool" type annotation .  For  Example      
var boolean = false 
or 
var boolean =  Bool()

if you want to use in an if else condition . you can do like that

if boolean == true {

// Statements

}

Here , boolean is variable name .You can take any variable name.