Post

GoLangGoLang

j
jordan chris

Posted on 27th February 2024|10 views

0
votes

Golang Return Multiple Values

How to return multiple values in Golang?

Answers
P
Harshel Mike

Posted on 27th February 2024

You can do it this way

package main

import "fmt"

func vals() (int, int){

return 6, 7

}

func main()

{

x, y := vals()

fmt.println(x)

fmt.println(y)

_, z := vals()

fmt.println(z)

}

Output:

6

7

7

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos