作者ireullin (raison detre)
看板java
標題[問題] scala中關鍵字與class中的method名字相同
時間Mon May 18 18:02:07 2015
請問一下各位
小弟在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.
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.225.108.86
※ 文章網址: https://www.ptt.cc/bbs/java/M.1431943331.A.D56.html
推 brianhsu: 加上 backtick 就可以囉:params.`match`(kw) 05/18 18:21
→ ireullin: 謝謝^^ 可以了 05/18 18:44