In many languages, on of the things I find myself doing is maping over a list to extract some field. For example, coverting a []Person to []Name.
Most languages these days have ways to do this pretty easily:
Kotlin:
people.map { it.Name } JavaScript:
people.map(p => p.Name) Rust:
people.map(|p| p.Name) Scala:
people.map(_.Name) With generics, Go finally can do this in a type safe manner:
Map(people, func(t Person) string { return t.
Ergonomic Map in Go | howardjohn's blog
In many languages, on of the things I find myself doing is maping over a list to extract some field. For example, coverting a []Person to []Name. Most languages these days have ways to do this pretty easily: Kotlin: people.map { it.Name } JavaScript: people.map(p => p.Name) Rust: people.map(|p| p.Name) Scala: people.map(_.Name) With generics, Go finally can do this in a type safe manner: Map(people, func(t Person) string { return t.
http://localhost:1313/posts/go-map/