How to get Ponter/Reference semantics in Scala.

Posted by Lukasz Lew on Stack Overflow See other posts from Stack Overflow or by Lukasz Lew
Published on 2010-05-09T20:51:13Z Indexed on 2010/05/09 20:58 UTC
Read the original article Hit count: 178

Filed under:
|
|
|
|

In C++ I would just take a pointer (or reference) to arr[idx].
In Scala I find myself creating this class to emulate a pointer semantic.

class SetTo (val arr : Array[Double], val idx : Int) {
  def apply (d : Double) { arr(idx) = d }
}

Isn't there a simpler way?
Doesn't Array class have a method to return some kind of reference to a particular field?

© Stack Overflow or respective owner

Related posts about scala

Related posts about scala-2.8