Golang : Valued expressions and functions example
Writing this simple example down here as a reminder for myself on how to use valued expressions in Golang. Nothing complicated, just a simple reminder for my old brain.
Here you go!
package main
import (
"fmt"
)
func main() {
// functions
g := func(x int) int { return x * 9 }
f := func() int { return 9 }
fmt.Println(g(f()))
// arithmetic
fmt.Println("One plus five is ", 1+5)
value := 2
fmt.Println(value * 2) // 4
fmt.Println(float64(value*16) / 2)
}
Output :
81
One plus five is 6
4
16
See also : Golang : Display list of time zones with GMT
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+8.1k Golang : Randomize letters from a string example
+9.2k Golang : does not implement flag.Value (missing Set method)
+7.1k Golang : Squaring elements in array
+46.5k Golang : Encode image to base64 example
+16.5k Golang : Get IP addresses of a domain name
+25.7k Golang : missing Mercurial command
+6.1k nginx : force all pages to be SSL
+14.6k Golang : Missing Bazaar command
+8.8k Golang : Get final balance from bit coin address example
+14.5k Android Studio : Use image as AlertDialog title with custom layout example
+7.6k Android Studio : AlertDialog to get user attention example