新的 lambda 语法是什么?
我听说 DMD 2.058 中将有一个用于匿名函数的新语法,但我找不到任何相关信息。新语法是什么?旧语法是否会被弃用?
I've heard there is going to be a new syntax in DMD 2.058 for anonymous functions, but I can't find any information on it. What is the new syntax, and is the old syntax going to be deprecated?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信它就像C#。
以下是等效的:
as are:
as are:
尽管我不确定新语法是否也支持显式返回类型。
I believe it's like C#'s.
The following are equivalent:
as are:
as are:
though I'm not sure whether explicit return types are also supported in the new syntax.
当前 lambda 功能没有被删除。只是为那些需要它的人引入了一种新的、更简洁的语法。正如 Merhdad 所说,它本质上是 C# 的语法,尽管我不知道它是否 100% 相同。
所以不要做类似的事情,而是
做类似的事情
No current lambda functionality is being removed. It's just that a new, terser syntax is being introduced for those who want it. As Merhdad says, it's essentially C#'s syntax, though I don't know if it's 100% identical.
So instead of doing something like
you do something like