user6912219 user6912219 - 1 year ago 133
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 Source
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.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download