Declare a constant

 Problem

I want to declare a new constant and assign it a value.



 Recipe


// This is an Integer constant
let a : Int = 2

// This is a String constant
let b : String = "My string"

// This is an Integer constant - no need to declare a type,
// since it's inferred from the right-hand side value
var c = 5
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground