Scala代码报错 type mismatch

猿来是我 2015-06-25 12:02:28
object testFun {

def methodA(x:Int) {
if (x>100)
println("greater than 100")
else
println("not greater than 100")
}


def apply7(f: Int => {}) {
print("go")
f(120)
}

def main(args:Array[String]) = {
apply7(methodA)
}


}



以上Scala代码报错:

prog.scala:38: error: type mismatch;
found : Unit
required: AnyRef

求帮助解决。
...全文
992 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zccao_gong 2015-06-28
  • 打赏
  • 举报
回复
package zccao /** * Created by Administrator on 2015/6/28. */ object testFun { def methodA(x:Int) { if (x>100) println("greater than 100") else println("not greater than 100") } def apply7(f: Int => Unit) { println("go") f(120) } def main(args:Array[String]) = { apply7(methodA) } }
猿来是我 2015-06-26
  • 打赏
  • 举报
回复
up..up

1,270

社区成员

发帖
与我相关
我的任务
社区描述
Spark由Scala写成,是UC Berkeley AMP lab所开源的类Hadoop MapReduce的通用的并行计算框架,Spark基于MapReduce算法实现的分布式计算。
社区管理员
  • Spark
  • shiter
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧