The Three Dots In Golang...
I was trying to implement a method where I remove a certain value from a slice. Then I came across this ... syntax. I didn't come across this three-dot syntax before. So I read about it and then found out that this syntax is used for multiple use cas...
blog.harishdurga.com2 min read
Nice one ! Also consider example with simple under(lying) type
package main import ( . "fmt" ) type under int // Based on (but with underlying type) : @blog.harishdurga.com/the-three-dots-in-golang // define ...rest like parameter for variadic functions func Sum(nums ...under) under { var r under = 0 for _, n := range nums { r += n } return under(r) } func main() { /* Println( Sum([]int{1,2,3}...) ) */// instead do: Println( Sum([]under{1,2,3}...) ) }