Does Go support lambda expressions or anything similar?
I want to port a library from another language that uses lambda expressions (Ruby).
The golang does not seem to make lambda expressions, but you can use a literal anonymous function, I wrote some examples when I was studying comparing the equivalent in JS, I hope it helps !!
func() string {
return "some String Value"
}
//Js similar: () => 'some String Value'
func(arg string) string {
return "some String" + arg
}
//Js similar: (arg) => "some String Value" + arg
func() {
fmt.Println("Some String Value")
}
//Js similar: () => {console.log("Some String Value")}
func(arg string) {
fmt.Println("Some String " + arg)
}
//Js: (arg) => {console.log("Some String Value" + arg)}