【发布时间】:2017-12-29 07:35:10
【问题描述】:
在 C# 中,我们可以使用 lambda 表达式编写类似以下的内容,我们如何在 GO 语言中实现这一点?基本上,我正在寻找一种将一些参数传递给函数的能力,然后在它们可用时将一些参数传递给函数。
myFunc = (x) => Test(123, x) // Method Test is declared below.
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)
{
// ...
}
【问题讨论】:
-
我认为这个问题已经回答了here。