While I was reading the code of package "net", I found some code like this:
// first returns the first address which satisfies strategy, or if
// none do, then the first address of any kind.
func (addrs addrList) first(strategy func(Addr) bool) Addr {
for _, addr := range addrs {
if strategy(addr) {
return addr
}
}
return addrs[0]
}
I am really confused about why the func first includes another func named func(Addr), and how does this code implement the behaviour which the comments say?