DEV Community

Discussion on: Functions in Go.

Collapse
 
dean profile image
dean

It’s not empty, in Go, the return type is after the function parameters. In this case, split returns (int, int), meaning it returns two integers

Collapse
 
hjfitz profile image
Harry

I understand that (int, int) means that it returns two integers, but I'm not sure where you state which integers?

It has me wondering because, in a function with more than two integers, what is returned?

func foo(a int) (int, int) {
  x := 1;
  y := 2;
  z := a * (x + y);
  return
}
Thread Thread
 
dean profile image
dean

Oh I see. Looks like the author forgot to put in the returned values, didn’t notice that!

Thread Thread
 
codehakase profile image
Francis Sunday

Oh.. I meant to use that syntax since I only had two variables I wanted to return. Thanks for your observations anyways.