带有示例的 Scala ListSet isEmpty() 方法
在 Scala ListSet 中,isEmpty() 方法用于检查 listSet 是否为空,如果为空则返回 true,否则返回 false。
Method Definition: defisEmpty: Boolean
Return Type: true if the list set contains no elements, false otherwise.
示例 1:
Scala
// Scala program of isEmpty()
// method
import scala.collection.immutable._
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Creating litset
val m1 = ListSet(1, 2, 3, 4, 5, 7)
// Applying filter method
val result = m1.isEmpty
// Displays output
println(result)
}
}
Scala
// Scala program of count()
// method
import scala.collection.immutable._
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Creating litset
val m1 = ListSet()
// Applying filter method
val result = m1.isEmpty
// Displays output
println(result)
}
}
输出:
false
示例 2:
斯卡拉
// Scala program of count()
// method
import scala.collection.immutable._
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Creating litset
val m1 = ListSet()
// Applying filter method
val result = m1.isEmpty
// Displays output
println(result)
}
}
输出:
true