Facebook
From PGHM, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 114
  1. 1> ["1", "two", "10"].compactMap { Int($0) }                 //=> [1, 10]
  2. 2> ["1", "two", "10"].compactMap(Int.init)                   //=> [1, 10]
  3. 3> ["1", "two", "10"].map { $0[...] }.compactMap { Int($0) } //=> [1, 10]
  4. 4> ["1", "two", "10"].map { $0[...] }.compactMap(Int.init)   //=> [0, 0, 0]