logo-MindMajix
PostGoLangGoLang
j
jordan chris

Posted on 21st July 2024|12 views

0
votes

Golang Return Multiple Values

How to return multiple values in Golang?

1 answers
Answers
P
Harshel Mike

Posted on 21st July 2024| views

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
Name
Course *
Email *
Phone Number