Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Math doesn't have vars, only vals


That's a rather strange assertion, if you mean "variables" and "values." Math distinguishes between variables and values. Variables have different values. Values can be bound to variables. Sometimes we do math with mostly variables and few values -- that's called algebra.


I mean Scala vars can be changed during the program, while Scala vals can't.

    val y = Console.readInt
    var x = y + 1
    x = y + 2 //valid
    y = 5 //error, vals can't be changed in the same block




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: