Scala Unit type

An assignment expression has type Unit in Scala. That is the reason for your compiler warning.

There is a nice idiom in Scala that avoids the while loop:

val iterator = Iterator.continually(reader.readNext()).takeWhile(_ != null)

This gives you an iterator over whatever reader.readNext returns.

The continually method returns an “infinite” iterator and takeWhile takes the prefix of that, up to but not including the first null.

(Scala 2.8)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)