2017-02-16 136 views
-6

我想返回兩個集合的工會以下列方式:無法解析符號++斯卡拉

type Set = Int => Boolean 
def union(s: Set, t: Set): Set = s ++ t 

我得到錯誤「無法解析符號++」。發生了什麼?

+0

你知道你的代碼還有其他一些問題嗎? –

+0

我不知道爲什麼我用++符號得到這個錯誤 – Andrew

+0

什麼是'Set'?它是'scala.collection.Set'? – mfirry

回答

0

type Set = Int => Boolean定義Set意味着功能從IntBoolean。功能上沒有++方法。而已。

+0

好吧,我很難理解這一點。 – Andrew

0

你需要指定的Set類型參數,如果你正在使用Scala的設置:

def union(s:Set[Int], t:Set[Int]):Set[Int] = s ++ t 
+0

可悲的是沒有工作:( – Andrew