Why index starts from 1 not from 0? http://www.scala-lang.org/docu/files/api/scala/io/Source.html
+1
A:
Line numbers traditionally start at 1. Wikipedia says:
The most common method of assigning numbers to lines is to assign every line a unique number, starting at 1 for the first line, and incrementing by 1 for each successive line.
The first high level programming language (Fortran) uses 1 for the index of the first element of an array. It was the C programming language that popularised using 0 for the first index.
atomice
2009-10-15 12:59:58
A:
Because humans normally start counting at 1. Class Source
in Scala is a representation of a source (text) file, and it's natural to start counting with the first line as number 1.
Jesper
2009-10-15 13:00:11
It'd be nice if Scala had an IO library and not something that is exists only to support their compiler. I think it's coming in 2.8.
arcticpenguin
2009-10-15 13:37:11
It is not coming in 2.8, but people are now actively discussing such a library. You can cheat and use functions from the compiler, though.
Daniel
2009-10-15 17:19:22