title: Passing Functions to Spark: What is the risk of referencing the whole object?
body: <p>According to <a href="https://spark.apache.org/docs/latest/programming-guide.html#resilient-distributed-datasets-rdds" rel="noreferrer">Passing Functions to Spark</a>,it claims:</p>
  
  <p><code>accessing fields of the outer object will reference the whole object; To avoid this issue ...</code></p>
  
  <p>I am considering that what is the risk of flowing code:</p>
  
  <pre><code>class MyClass {
    val field = "Hello"
    def doStuff(rdd: RDD[String]): RDD[String] = { rdd.map(x =&gt; field + x) }
  }
  </code></pre>
  
  <p><strong>references all of this</strong> would do any harm ?</p>