Hi,

I'm new to Spark and Scala as well. I understand that we can use foreach to
apply a function to each element of an RDD, like rdd.foreach
(x=>println(x)), but I saw we can also do a for loop to print each element
of an RDD, like 

for (x <- rdd){
println(x)
}

Does defining the foreach function in RDD make an RDD traversable like this?
Does the compiler automatically invoke the foreach function when it sees a
for loop? 


Thanks!
Phil





--
View this message in context: 
http://apache-spark-user-list.1001560.n3.nabble.com/RDD-for-loop-vs-foreach-tp27326.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe e-mail: user-unsubscr...@spark.apache.org

Reply via email to