How to use If with a short statement (statement execute before the condition) in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"math"
)

func short_if(x, y, f float64) string {
	if pw := math.Pow(x, y); pw < f {
		return "yes"
	}
	return "no"
}

func main() {
	fmt.Println(short_if(4, 2, 30))
	fmt.Println(short_if(4, 3, 20))
}


/*
run:

yes
no

*/

 



answered Mar 6, 2020 by avibootz

Related questions

1 answer 202 views
1 answer 161 views
1 answer 281 views
281 views asked Oct 28, 2020 by avibootz
1 answer 286 views
1 answer 246 views
246 views asked Feb 29, 2020 by avibootz
1 answer 192 views
1 answer 195 views
...