Swift: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
Line 23: Line 23:
}
}
</syntaxhighlight>
</syntaxhighlight>
==Switch Statements==
No surprises
switch a {
  case "a":
      print("we are here a")
  case "b":
      print("we are here b")
  default:
      print("we are here not a or b")
}

Revision as of 00:06, 24 June 2022

Introduction

Here is my first dip into Apple and swift Swift Cheat Sheet

Data Types

Here we have the following Primatives

  • Int
  • Float
  • Double
  • Str
  • Bool

Control

If Statements

No surprises

if a < 4 {
  print("we are here 1")
}
else if a == 4 && a < 3 {
  print("we are here 2")
}
else {
  print("we are here 3")
}

Switch Statements

No surprises switch a {

  case "a":
     print("we are here a")
  case "b":
     print("we are here b")
  default:
     print("we are here not a or b")

}