aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/programming-guide.md7
1 files changed, 5 insertions, 2 deletions
diff --git a/docs/programming-guide.md b/docs/programming-guide.md
index bad25e63e8..4d21d4320c 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>