diff --git a/docs/programming-guide.md b/docs/programming-guide.md index bad25e63e89e6ef94948d495c4f4e848dc09dd70..4d21d4320c50d0f72c871644bdfb3fc8797c8b55 100644 --- a/docs/programming-guide.md +++ b/docs/programming-guide.md @@ -789,9 +789,12 @@ counter = 0 rdd = sc.parallelize(data) # Wrong: Don't do this!! -rdd.foreach(lambda x: counter += x) +def increment_counter(x): + global counter + counter += x +rdd.foreach(increment_counter) -print("Counter value: " + counter) +print("Counter value: ", counter) {% endhighlight %} </div>