Skip to content

Instantly share code, notes, and snippets.

@suraphanL
Created February 24, 2017 17:32
Show Gist options
  • Save suraphanL/e3a26b518c02cf71204da345cd74b2c5 to your computer and use it in GitHub Desktop.
Save suraphanL/e3a26b518c02cf71204da345cd74b2c5 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
struct Mobile {
let number: String
let status: String
}
let mobiles = [Mobile(number: "081XXXXXXX", status: "Y"),
Mobile(number: "082XXXXXXX", status: "Y"),
Mobile(number: "083XXXXXXX", status: "N"),
Mobile(number: "084XXXXXXX", status: "Y")]
let mobileNumbers = mobiles.filter { $0.status == "Y"}.map {$0.number }
let string = mobileNumbers.joined(separator: ", ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment