Skip to content

Instantly share code, notes, and snippets.

View TungVdMiichi's full-sized avatar

Tung Vu Duc TungVdMiichi

  • Miichisoft
  • Vietnam
View GitHub Profile
var urls = [URL]()
for item in items {
if let url = item.thumbnailURL {
urls.append(url)
}
}
struct FeedItem {
let title: String
let thumbnailURL: URL?
}
let items = [FeedItem(title: "title", thumbnailURL: nil),
FeedItem(title: "another title", thumbnailURL: URL(string: "http:b-url.com")!),
FeedItem(title: "even another title", thumbnailURL: URL(string: "http:c-url.com")!),
FeedItem(title: "even another another title", thumbnailURL: URL(string: "http:d-url.com")!)]
let urls = items.map { (item) -> URL in
return item.thumbnailURL
}
let urls = items.map{$0.thumbnailURL}
var urls = [URL]()
for item in items {
urls.append(item.thumbnailURL)
}
struct FeedItem {
let title: String
let thumbnailURL: URL
}
let items = [FeedItem(title: "title", thumbnailURL: URL(string: "http:a-url.com")!),
FeedItem(title: "another title", thumbnailURL: URL(string: "http:b-url.com")!),
FeedItem(title: "even another title", thumbnailURL: URL(string: "http:c-url.com")!),
FeedItem(title: "even another another title", thumbnailURL: URL(string: "http:d-url.com")!)]
class TestGist {
}