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
+26.4k Golang : Move file to another directory
+4.7k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+3.5k Java : Generate multiplication table example
+8.4k Facebook : Getting the friends list with PHP return JSON format
+10.4k Swift : Convert (cast) Float to String
+5.7k Golang : Warp text string by number of characters or runes example
+4.1k Golang : Check if a word is countable or not
+9.1k Golang : Embed secret text string into binary(executable) file
+10.7k Golang : How to detect a server/machine network interface capabilities?
+10k Golang : How to use if, eq and print properly in html template
+17.2k Golang : Send email with attachment
+19.9k Golang : Sort and reverse sort a slice of strings