Swift 5.1: Declaring Constants and Variables Cheat Sheet

// Declaring a constant using the let keyword
let double: Double = 2.0
// double = 3.0 // Error: You can't reassign a let
let inferredDouble = 2.@ // Inferred as a Double
// Declaring a variable using the var keyword
var mutableInt: Int = 1
mutableInt = 2 // OK: You can reassign a var

Leave a Reply

Your email address will not be published. Required fields are marked *