English 中文(简体)
混凝土
原标题:Scala lift type mismatch?

我目前正在设计一个网络应用程序,我希望从提交表格中获取一个价值,但获得一种类型的不匹配:

类型不匹配;发现:连接。 选择要求:(a) =>

我的法典认为:

var value=0
 "name=value" #> SHtml.onSubmit(s => asInt(s).foreach(value= _)) &
 // when the form is submitted, process the variable
"type=submit" #> SHtml.onSubmitUnit(askForHumanMove)

以及我对人类提出的要求 循环方法:

def askForHumanMove(board: connectfour.Board): Option[Int] = {
    Some(value)        
}

希望有些人能够帮助我处理这种不匹配问题。

谢谢!

Best regards, John

问题回答

参看<代码>onSubmitUnit接受=> 任何作为参数。 但是,你正在采用一种将取消为<条码>/Board => 备选案文[Int]的方法。 这些类型不兼容。

您在请设<代码>onSubmitUnit方法时是否具备Board的相关实例? 如果是的话,固定办法简单:

"type=submit" #> SHtml.onSubmitUnit( () => askForHumanMove(board) )




相关问题
How to flatten a List of different types in Scala?

I have 4 elements:List[List[Object]] (Objects are different in each element) that I want to zip so that I can have a List[List[obj1],List[obj2],List[obj3],List[obj4]] I tried to zip them and I ...

To use or not to use Scala for new Java projects? [closed]

I m impressed with Twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java? EDIT: And, ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Include jar file in Scala interpreter

Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a ...

Scala and tail recursion

There are various answers on Stack Overflow which explain the conditions under which tail recursion is possible in Scala. I understand the limitations and how and where I can take advantage of tail ...

热门标签