Scala Iterator buffered() method with example
The buffered() method in Scala belongs to the concrete value members of the class iterator of Scala. It creates a buffered iterator from the iterator stated.
Example :
object GfG
{
def main(args : Array[String])
{
val iter = Iterator( 3 , 4 , 5 , 6 , 7 )
val result = iter.buffered
println(result)
}
}
|
Output:
non-empty iterator
Here, a buffered iterator of the stated iterator is returned after applying buffered method.
Example :
object GfG
{
def main(args : Array[String])
{
val iter = Iterator()
val result = iter.buffered
println(result)
}
}
|
Here, the stated iterator is empty so, an empty buffered iterator is returned after applying buffered method.
Last Updated :
28 May, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...