4 ms·
Not sure generics are amazing. I wish I could do something like addresses := persons.map(func(p Person) Address {p.address}) Actually what I really want is a
by eweise 4y ago
Not sure generics are amazing. I wish I could do something like
addresses := persons.map(func(p Person) Address {p.address})
Actually what I really want is
addresses := persons.map(p => p.address)
But I understand Go doesn't allow that level of readability.
- throwawaygal7 4y agoSo you just want implicit returns?
- eweise 4y agoI want to be able to define generics on methods, not just functions.
- valzam 4y agoAs someone who wrote scala and elixir for a few years and recently switched to a Go job I also dearly missed map and filter. However, people tend to loop unnecessarily often when it's so easy. Say you have a list of classes and want to pull out certain fields. With immutability as default and easy map functions many people write something like this: a = my list.map(e => e.foo) b = mylist.map(e => e.bar) This may or may not matter performance wise but I think Go has a strong culture of of making something like this easy vs writing a for loop that does everything in one go.
- doorman2 4y agoYes, succinctness is almost never in Go's favor.