swift3 - Create a new String Array from class array -


i have class called person:

class person {      var firstname: string?     var lastname: string?     let birthplace = "belgium"  }   let person = [person]() 

now problem want first names string array ([string]), how can it?

you can use flatmap that:

let firstname = person.flatmap{ return $0.firstname } 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -