Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
!rant
I've been working with Golang for a while now and I've come to love the generics they introduced. Making stuff type-safe is a bit of a hassle, but it pays off greatly.
One thing I had yet to consider though, is that functions are also a type, so that those could be made generic too.
func DoThing[F func(string) | func(int)](callback F) {...}
Now you can deliver both function types and I can differentiate them using a type switch.
Weird that sometimes my brain doesn't make that connection immediately...
rant