Skip to content

Instantly share code, notes, and snippets.

View Mayankgupta688's full-sized avatar
💭
Corporate and Online Trainer with 8+ years of Experience...

Mayank Gupta Mayankgupta688

💭
Corporate and Online Trainer with 8+ years of Experience...
View GitHub Profile
package main
import "fmt"
func main() {
variableOne := 10
variableTwo := 20
updateData(variableOne, variableTwo)
fmt.Println("Value of variable one in main Function is", variableOne)
}
package main
import "fmt"
func main() {
getData(10, 20)
}
func getData(inputData ...int) {
for value, index := range inputData {
fmt.Printf("Value at index %d is %d \n", value, index)
package main
import "fmt"
func main() {
getData(1, 2)
getData(1, 2, 3)
}
func getData(inputData ...int) {
fmt.Println("Number of Parameter Received:", len(inputData))
package main
import "fmt"
func main() {
fmt.Printf("Hello world, the first parameter is: %d", 42)
fmt.Printf("Hello world, the first parameter is: %d, second parameter is %d", 42, 32)
}
package main
import "fmt"
func main() {
userName, _ := getValues()
fmt.Println("User Name is:", userName)
}
func getValues() (string, int) {
return "Mayank", 34
package main
import "fmt"
func main() {
userName, userAge := getValues()
fmt.Println("User Name is:", userName)
fmt.Println("User Age is:", userAge)
}
package main
import "fmt"
func main() {
userName, userAge, isDeveloper := getValues()
fmt.Println("User Name is:", userName)
fmt.Println("User Age is:", userAge)
fmt.Println("Is User a Developer:", isDeveloper)
}
package main
import "fmt"
func main() {
userName, userAge, isDeveloper := getValues()
fmt.Println("User Name is:", userName)
fmt.Println("User Age is:", userAge)
}
func getValues() (string, int) {
@Mayankgupta688
Mayankgupta688 / multipleFunctionReturn.go
Last active March 20, 2023 03:36
Return Multiple Values from Function
package main
import "fmt"
func main() {
variableOne, variableTwo := getValues()
fmt.Println("Value for variable one is:", variableOne)
fmt.Println("Value for variable two is:", variableTwo)
}
func getValues() (int, int) {
package main
import "fmt"
func main() {
returnedData := func() func() {
return func() {
fmt.Println("Data Returned from Function")
}
}()