title: What replaces class variables in scala?
body: <p>In Java I sometimes use class variables to assign a unique ID to each new instance. I do something like</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Foo {
  
    private static long nextId = 0;
  
    public final long id;
  
    public Foo() {
      id = nextId;
      nextId++;
    }
  
    [...]
  
  }
  </code></pre>
  
  <p>How can I do this in Scala?</p>