News Score: Score the News, Sort the News, Rewrite the Headlines

"Generic Methods in Go 1.27"

When Go 1.18 introduced Generics in 2022, it brought generic type parameters to functions and structs, but left out methods. With the release of Go 1.27, this long-standing limitation has been removed. Methods can now define their own type parameters without adding them to the receiving struct.Why this change was introducedIf you want to create a graph node that holds a generic value, you might implement it like this:type Node[T any] struct { value T } Imagine adding a method Map that transforms...

Read more at dominik.info

© News Score  score the news, sort the news, rewrite the headlines