Home > OS >  What the different between those two Golang function return
What the different between those two Golang function return

Time:01-07

What the different between those two Golang functions, are they the same with each other?

func foo1() (ret string) {
    ret = "hi there"
    return
}

func foo2() string {
    ret := "hi there"
    return ret
}

which is better?

CodePudding user response:

These two functions are identical: https://go.dev/play/p/_6KT5thL2Sj

  •  Tags:  
  • Related