“With” statement equivalent for Scala?

前端 未结 6 883
野的像风
野的像风 2021-02-13 10:31

Idle pondering from a Scala learner perhaps, but ... in my tinkerings I\'ve written the following:

( n.child.size > 0 ) && ( n.child.filter( ! _.isIns         


        
6条回答
  •  生来不讨喜
    2021-02-13 10:58

    you can use match for that purpose.

    n.child match {
    case list => ( list.size > 0 ) && ( list.filter( ! _.isInstanceOf[Text] ).size == 0 )
    }
    

提交回复
热议问题