Meaning of …interface{} (dot dot dot interface)

前端 未结 2 1519
忘了有多久
忘了有多久 2020-12-04 06:37

Below is a piece of Go code I have question about. Specifically, what is a in this function?

func DPrintf(format string, a ...interface{}) (n in         


        
2条回答
  •  無奈伤痛
    2020-12-04 07:04

    As far as the interface{} term, it is the empty interface. In other words, the interface implemented by all variables in Go.

    This is sort of analogous to java.lang.Object or System.Object in C#, but is instead inclusive of every variable type in the language. So it lets you pass in anything to the method.

提交回复
热议问题