Skip to content

How to handle Option in the case of multiple return values? #23956

Closed Answered by JalonSolov
hellolio asked this question in Questions and Answers
Discussion options

You must be logged in to vote

If the names a1 and b1 offend you, assign the returns from foo() to dummy vars, then use a and b instead of a1 and b1...

fn main() {
	foo_r1, foo_r2 := foo()
	a := foo_r1 or { -1 }
	b := foo_r2 or { "qqq" }
	println('a: ${a} b:${b}')
}

fn foo() (?int, ?string) {
	return none, 'eee'
}

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@hellolio
Comment options

@JalonSolov
Comment options

@JalonSolov
Comment options

Answer selected by hellolio
@hellolio
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants