harlixxy / x-x-x

记录及解答与大数据IMF相关的问题
6 stars 0 forks source link

scala 类型参数,类型约束 报错 #1

Closed thinktothings closed 8 years ago

thinktothings commented 8 years ago

/\

def correspondsB(match: (A,B) => Boolean):Boolean

/* 报错信息 */ Error:(48, 38) Wrong top statement declaration

harlixxy commented 8 years ago

查看下def 定义语法。 错误相关描述:

  1. A类型未定义
  2. B是泛型,加中括号
  3. match : 关键字,改名
  4. def需要定义实体,也就是要添加函数体 类似语句: scala> def corresponds[A,B](a:%28A,B%29 => Boolean):Boolean = true corresponds: [A, B](a: %28A, B%29 => Boolean)Boolean