【问题标题】:What Is The Difference Between Functions Definitions And Class Definitions函数定义和类定义有什么区别
【发布时间】:2017-06-29 05:49:33
【问题描述】:

我遇到了这种情况。

class Test(a: List[Int])(b: a.type) //This won't compile
def test(a: List[Int])(b: a.type) = ??? //This will compile

有人可以向我解释这是为什么吗?

【问题讨论】:

标签: scala methods constructor case-class


【解决方案1】:

这不是函数定义,而是方法定义。另一个是类定义。该功能称为依赖方法类型。换句话说:它是方法的一个特征。类不是方法。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-09-24
  • 2016-09-06
  • 1970-01-01
  • 2011-08-20
  • 1970-01-01
  • 2018-07-06
相关资源
最近更新 更多