class - Defining classes: difference between var, val and leaving it out? -


this question has answer here:

what difference between following 3 scala declarations? understand general distinction between val , var.

class a(x: t){ ... } class b(val x: t){ ... } class c(var x: t){ ... } 

difference between a , b (both val , var create accessor):

class a(a: int) {}  // doesn't compile (value not member of) // (new a(1)).a  class b(val b: int) {}  (new b(1)).b                                    //> res0: int = 1 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -