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 95 views
1 answer 67 views
1 answer 194 views
194 views asked Oct 28, 2020 by avibootz
1 answer 195 views
1 answer 159 views
159 views asked Feb 29, 2020 by avibootz
1 answer 91 views
1 answer 75 views
...