[问题] scala中关键字与class中的method名字相同

楼主: ireullin (raison detre)   2015-05-18 18:02:07
请问一下各位
小弟在scala中使用redis的library
https://github.com/xetorthio/jedis
其中 ScanParams 中有一个method的名称叫做match
与scala中的关键字重复了
请问这时候要如何处理?
因为看来编译器把这个match当成语法中的match了
我写法如下
val params = new ScanParams()
params.match(kw)
错误讯息
error: identifier expected but 'match' found.
error: '{' expected but '(' found.
作者: brianhsu (坟墓)   2015-05-18 18:21:00
加上 backtick 就可以囉:params.`match`(kw)
楼主: ireullin (raison detre)   2015-05-18 18:44:00
谢谢^^ 可以了

Links booklink

Contact Us: admin [ a t ] ucptt.com