LoginSignup
2
3

More than 5 years have passed since last update.

[Swift] Swift Memo

Last updated at Posted at 2015-08-03
  • Default Value
b = a ?? "empty"
//equals
b = (a == nil ? "empty" : a!)
  • Dictionary
var dic1 = [String:Any]()
//equals
var dic2 = Dictionary<String,Any>()
  • Sort
var a = [10, 5, 2, 3, 1]

a.sort({x, y in x > y})
a.sort({$0 > $1})
sort(&a, {$0 > $1})
  • Spilit string
let array = split(str!) { $0 == " " }
2
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3