title: How do I expose Scala constructor arguments as public members?
body: <p>Look at this example:</p>
  
  <pre><code>class Point(x: Double, y: Double){
    override def toString = "x: " + x + ", y: " + y
    def +(sourcePoint: Point) : Point = {
      return new Point(x + sourcePoint.x, y + sourcePoint.y
    }
  }
  </code></pre>
  
  <p>As you can see I want to define a <code>+</code> operator method on the Point class. But this won't work
  because in that method, <code>x</code> and <code>y</code> can't be accessed on the <code>sourcePoint</code> local variable since they are private, so I changed the example into this:</p>
  
  <pre><code>class Point(_x: Double, _y: Double){
    var x = _x
    var y = _y
  
    override def toString = "x: " + x + ", y: " + y
    def +(sourcePoint: Point) : Point = {
      return new Point(x + sourcePoint.x, y + sourcePoint.y)
    }
  }
  </code></pre>
  
  <p>That obviously worked, however is there an easier way to define these variables instead of going from _x -> x and _y -> y. </p>
  
  <p>Thanks for help and time! :)</p>