Scala Iterator product() method with example
Last Updated :
13 Aug, 2019
The product() method belongs to the concrete value member of the class Abstract Iterator. It is utilized to Multiply all the elements of the stated collection.
Method Definition: val result = iter.product
Return Type: It returns the result obtained by multiplying all the elements of the stated iterator.
Example #1:
object GfG
{
def main(args : Array[String])
{
val iter = Iterator( 1 , 2 , 3 , 4 , 5 , 6 )
val result = iter.product
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val iter = Iterator( 0 , 1 )
val result = iter.product
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...