Sunday, November 15, 2015

while ((line = readLine()) != "") doesn't work in Scala

In C++ or Java, line = readLine() would return the line itself, however, in Scala, assignment to var type variable returns () i.e. Unit, so it cannot be compared to "" in a while loop.

Pure functional languages do not have loops because of this same reason, it does not return anything

No comments: