user6912219 user6912219 - 23 days ago 4x
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?

You can declare a Boolean variable using "Bool" type annotation .  For  Example      
var boolean = false 
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.