Skip to content

Booleans in Swift

This tutorial belongs to the Swift series

Swift provides the Bool type, which can have two values: true and false.

var done = false
done = true

Booleans are especially useful with conditional control structures like if statements or the ternary conditional operator:

var done = true

if done == true {
    //code
}

→ Get my Swift Handbook

I wrote 21 books to help you become a better developer:

  • HTML Handbook
  • Next.js Pages Router Handbook
  • Alpine.js Handbook
  • HTMX Handbook
  • TypeScript Handbook
  • React Handbook
  • SQL Handbook
  • Git Cheat Sheet
  • Laravel Handbook
  • Express Handbook
  • Swift Handbook
  • Go Handbook
  • PHP Handbook
  • Python Handbook
  • Linux Commands Handbook
  • C Handbook
  • JavaScript Handbook
  • Svelte Handbook
  • CSS Handbook
  • Node.js Handbook
  • Vue Handbook
...download them all now!

Related posts that talk about swift: