Scratchpad & notes about Swift.
Swift | JavaScript | |
---|---|---|
Literal String | ||
Literal Boolean | ||
Null pointer | ||
Equality operator | ||
Comments | ||
Literal Array | ||
Literal Object | ||
Reference to Owner | ||
Debugging Print | ||
String Interpolation | ||
Increment & decrement operators | ||
Pushing onto an array | ||
Concatentating arrays | ||
Counting for loop | ||
Function | ||
Lambda |
Swift | JavaScript | |
---|---|---|
HTTP Requests | Alamofire, PMHTTP | request |
Redux | ReSwift | Redux |
In both Swift and JavaScript, let
lets you assign a variable and bans future re-assignment to that variable. But in Swift, that value is also immutable. It’s helpful to think of Swift let
as JavaScript const
and Swift var
as JS let
.
let a = 0
// In swift, the following line will cause an error
let a = 1
// and this line is also wrong
a = a + 1
let a = 0
// In javascript, the following line will cause an error
let a = 1
// but this line will not. the value is mutable
a = a + 1