Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Scala中将拆分的字符串数组转换为集合_Scala - Fatal编程技术网

在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

在下一个Scala函数中:

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))