Quick actions

cmd+k|ctrl+k

Navigation

Languages

if, switch, goto / if statement / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-08-24T15:46:25Z

Updated

2019-08-24T15:46:25Z

package main

import "fmt"

func returnValues(ok bool) (int, bool) {
	return 5, ok
}

func main() {
	a := 5
	b := 5
	if a == b {
		fmt.Print("a is equal to b\n")
	} else {
		fmt.Print("a is not equal to b\n")
	}

	if n, ok := returnValues(true); ok {
		fmt.Print("ok is true, n: %d\n", n)
	} else {
		fmt.Print("ok is false, n: %d\n", n)
	}
}
INFO