在Scala中将拆分的字符串数组转换为集合
在下一个Scala函数中:在Scala中将拆分的字符串数组转换为集合,scala,Scala,在下一个Scala函数中: def usersForDepartments(colDeptIds: Option[String]) = Action.async { request => { println(colDeptIds) for { users <- Users.getAll(u => u.department in (colDeptIds.ge
def usersForDepartments(colDeptIds: Option[String]) = Action.async {
request => {
println(colDeptIds)
for {
users <- Users.getAll(u => u.department in (colDeptIds.getOrElse("").split(";").toSet))
} yield Ok( Json.stringify(convertUsersToJsonOrig(users)))
}
}
但我得到了一个错误:
scala:82: polymorphic expression cannot be instantiated to expected type;
[error] found : [B >: String]scala.collection.immutable.Set[B]
[error] required: slick.lifted.Query[slick.lifted.Rep[?], ?, ?]
[error] users <- Users.getAll(u => u.department in (colDeptIds.getOrElse("").split(";").toSet))
scala:82:多态表达式无法实例化为预期类型;
[错误]找到:[B>:字符串]scala.collection.immutable.Set[B]
[错误]必填项:slick.lifted.Query[slick.lifted.Rep[?],?,?]
[错误]用户位于(colDeptIds.getOrElse(“”.split(“”.toSet))中的u.department
需要帮忙吗?这个Scala的东西可能会让人困惑 错误表明您成功地创建了
Set[String]
,但这不是方法中的正确类型。我用inSet进行了修改,并对其进行了编译。THX错误表示您成功创建了集合[String]
,但这不是方法中的正确类型。对。我用inSet进行了修改,并对其进行了编译。谢谢
scala:82: polymorphic expression cannot be instantiated to expected type;
[error] found : [B >: String]scala.collection.immutable.Set[B]
[error] required: slick.lifted.Query[slick.lifted.Rep[?], ?, ?]
[error] users <- Users.getAll(u => u.department in (colDeptIds.getOrElse("").split(";").toSet))