Last active
December 27, 2015 11:40
-
-
Save aalemayhu/90ba76e1ab3222ea7ef8 to your computer and use it in GitHub Desktop.
trying out map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Named { | |
let name: String | |
init(name: String) { | |
self.name = name | |
} | |
} | |
let cat = Named(name: "cat") | |
let dog = Named(name: "dog") | |
let catDow = Named(name: "catDog") | |
let animals = [cat, dog, catDow] | |
let animalNames = animals.map { "\($0.name)" }.joinWithSeparator(", ") | |
print(animalNames) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment