Go and lambda expressions

In C#, we can write something like following using lambda expression, how can we achieve this in GO language? Basically, I am looking for an ability to pass some params to the function upfront and some params later when they are available.

myFunc = (x) => Test(123, x)

myFunc(“hello”) // this calls method Test with params int 123 & string “hello” where int was passed upfront whereas string was passed when Test is actually called on this line

void Test(int n, string x) { … }

myFunc := func(x string) { Test(123, x) }
myFunc("Hello")

where you have a previous func Test(n int, x string).

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.