A quick reference guide for the Swift programming language covering the primary types, including Number, String, and Bool, and advanced data structures like Set, Array and Dictionary
// This is a single-line comment
/*
This is a
multi-line comment
*/
typealias Integer = Int
let myInteger: Integer = 0
// Declare a constant
let pi = 3.14159
// Declare a variable
var radius = 5.0
// Define a custom type
struct Circle {
var radius: Double
var area: Double {
return pi * radius * radius
}
}
// Convert between types
let diameter = Int(radius * 2)
let circle = Circle(radius: radius)