Scala Iterator isTraversableAgain() method with example
Last Updated :
28 May, 2019
The isTraversableAgain() method belongs to the concrete value member of the class iterator in Scala. It checks whether the iterator can be repeatedly traversed or not.
Example :
object GfG
{
def main(args : Array[String])
{
val iter = Iterator( 3 , 1 , 7 , 9 , 15 )
val result = iter.isTraversableAgain
println(result)
}
}
|
Here, the iterator cannot be traversed repeatedly so, it returns false.
Example :
object GfG
{
def main(args : Array[String])
{
val iter = Iterator()
val result = iter.isTraversableAgain
println(result)
}
}
|
Here, we have declared an empty iterator and even that cannot be traversed repeatedly so, the method returns false.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...