Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
Created March 17, 2010 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuroyoro/335044 to your computer and use it in GitHub Desktop.
Save yuroyoro/335044 to your computer and use it in GitHub Desktop.
object PrintWithLineNumber{
import scala.io.Source
def printWithLineNumber( fileName:String ) =
Source.fromFile( fileName ).
getLines.
zipWithIndex.
map{ case ( s, n ) => "%s:%s" format( n, s ) }.
foreach{ print }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment