
Understand the various use cases of the three dots in the Go Language.
Full Stack Dev. I share my learnings.
I am full stack developer. I work on fun projects in my free time. At present my primary tech stack is Laravel and Vue js. I am in the process of expanding my tech stack. Go, Python, Cloud, Rust etc.
Markdown supported · ⌘↵ to post
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}...) ) }