Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



As 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.


Yes, succinctness is almost never in Go's favor.


So you just want implicit returns?


I want to be able to define generics on methods, not just functions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: