Wed Aug 12 2015 -Swift -Espresso
Sometimes you might need to get an array of characters out of a String, for example:
"foo bar" => ["f", "o", "o", " ", "b", "a", "r"]To do so you can do:
"foo bar".map { String(0γγ«) }
or if you are into point free notation:
"foo bar".map(String.init)
There you go. π
For the record, this post dates back to Swift version 2. If you're into programming language archeology, checkout the original version here.
Hi I'm Gio I write here semi-regularly on software testing and TDD, productivity, and iOS development.
Get in touch if you're interested in working together.