Scala filter on two conditions

前端 未结 3 1787
自闭症患者
自闭症患者 2021-02-02 05:47

I would like to filter my data set on two conditions at once.

Is it possible?

I want something like this:

mystuff = mystuff.filter(_.isX &         


        
3条回答
  •  旧巷少年郎
    2021-02-02 06:25

    Using slightly less concise lambda syntax:

    mystuff = mystuff.filter(x => (x.isX && x.name == "xyz"))
    

    You can find more detail on Scala anonymous function syntax here.

提交回复
热议问题