I am trying to understand how foreach
method works. In my jupyter notebook, I tried :
def f(x): print(x)
a = sc.parallelize([1, 2, 3, 4, 5])
b = a.foreach(f)
print(type(b))
<class 'NoneType'>
I can execute that without any problem, but I don't have any output except the print(type(b))
part. The foreach
doesn't return anything, just a none type. I do not know what foreach
is supposed to do, and how to use it. Can you explain me what it is used for ?