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
+15.7k Golang : Generate universally unique identifier(UUID) example
+10.1k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+7.7k Javascript : Put image into Chrome browser's console
+6.3k Golang : How to determine if request or crawl is from Google robots
+8.6k Golang : Find network service name from given port and protocol
+7k CloudFlare : Another way to get visitor's real IP address
+5.7k Golang : Extract unicode string from another unicode string example
+16.7k Golang : Get input from keyboard
+28.7k Golang : Get first few and last few characters from string
+10.2k Swift : Convert (cast) String to Integer
+44.4k Golang : Use wildcard patterns with filepath.Glob() example