Given a Person struct
struct Person {
let name: String
let birthYear: Int?
}
and an Array of Person(s)
let persons = [
Person(name: "Walter White", birthYear: 1959),
Person(name: "Jesse Pinkman", birthYear: 1984),
Person(name: "Skyler White&quo...
Applying a function to a collection/stream and creating a new collection/stream is called a projection.
/// Projection
var newReleases = [
[
"id": 70111470,
"title": "Die Hard",
"boxart": "http://cdn-0.nflximg.com/images...
Create a stream by selecting the elements from a stream that pass a certain condition is called filtering
var newReleases = [
[
"id": 70111470,
"title": "Die Hard",
"boxart": "http://cdn-0.nflximg.com/images/2891/DieHard.j...
Frequently you may want to filter structures and other complex data types. Searching an array of structs for entries that contain a particular value is a very common task, and easily achieved in Swift using functional programming features. What's more, the code is extremely succinct.
struct Painter...