i'm a beginner in scala. All i've to do now is to parse a file whose content is somewhat like this
You can't legislate morality... but it seems that morons can be legislators.
Lottery: A tax on people who are bad at math.
These are questions for action, not speculation, which is idle.
-- Noam Chomsky
If you think education is expensive try Ignorance.
-- Derek Bok, president of Harvard
Photons have neither morals nor visas.
-- Dave Farber
Maturity is not a factor of the games we play but the occasions we play them!
Design a system an idiot can use and only an idiot will want to use it.
It is much more rewarding to do more with less.
-- Donald Knuth
I came up up till this
import scala.io._
object parseFile {
var sample : Array[String]= new Array[String](20)
var anyName = List[Map[String,String]]()
def main(args:Array[String]):Unit = {
println("Hello, Scala !! ")
for(line <- Source.fromFile("myFile.txt").getLines())
//sample = line.split("--")
anyName = Map("quote" -> line):: anyName
println(anyName)
}
}
every line is going to "quote" in the list separately along with the author name as a separate line but i want another entry in the list as "author" which should take the line preceded by "--" and should split it.
Basically i want to separate quote and author and save it in a list.
Thanks in advance