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

vb.net - Alternative to the T-SQL AS keyword -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

ios - CFRelease causing crash in iPad application -