It's not that clear what you are trying to achieve - what type is myRDD and where do k and v come from?
Anyway it seems you want to end up with a map or a dictionary which is what PairRDD is for e.g. val rdd = sc.makeRDD(Array("1","2","3")) val pairRDD = rdd.map(el => (el.toInt, el)) ----- Robin East Spark GraphX in Action Michael Malak and Robin East Manning Publications Co. http://www.manning.com/books/spark-graphx-in-action -- View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/How-to-modify-collection-inside-a-spark-rdd-foreach-tp27088p27095.html Sent from the Apache Spark User List mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@spark.apache.org For additional commands, e-mail: user-h...@spark.apache.org