Open JOJO0527 opened 2 years ago
Currently, Go does not supports generic for methods.
This can never work because the result of the first call is just a Go slice and will not provide the functions of lo. It could, if lo provides another package like loc (for chaining), which returns an instance of lo, which then provides all the functions underneath. But then a final consumer call is needed as well. That’s missing in your „it doesn’t work“ (because it’s probably based on JS). In Java this is called „collect“. But collect would be also misleading, because this chaining here in Go would never be lazy.
Anyway, I would love to see this feature as well. I think with a generic interface, which defines all functions of lo on a pointer receiver and a final consumer function this could be possible.
This would be really cool.
It seems that lo can't do any chain opertaions like
It will be supported in the future? May be we can introduce a middle data stream like the stream operation in Java