Und noch einmal den Inhalt einer Textdatei ... Scala (3)
Scala
Gestern habe ich ja den Inhalt mittels println ausgegeben -> heute mache ich es so ->
package hello
import scala.io.Source
object ReadFromFile {
def myfunc(xs:String) {
println(xs);
}
def main(args:ArrayString) {
Source.fromFile(args(0)).getLines.foreach(myfunc);
}
}
....
Kategorie Gestern habe ich ja den Inhalt mittels println ausgegeben -> heute mache ich es so ->
package hello
import scala.io.Source
object ReadFromFile {
def myfunc(xs:String) {
println(xs);
}
def main(args:ArrayString) {
Source.fromFile(args(0)).getLines.foreach(myfunc);
}
}
....
Die zweite Variante ist die Benutzung von
Any ->
package hello
import scala.io.Source
object ReadFromFile {
def myfunc(xs:Any) {
println("+"+xs);
}
def main(args:ArrayString) {
Source.fromFile(args(0)).getLines.foreach(myfunc);
}
}
Gruß JJR
package hello
import scala.io.Source
object ReadFromFile {
def myfunc(xs:Any) {
println("+"+xs);
}
def main(args:ArrayString) {
Source.fromFile(args(0)).getLines.foreach(myfunc);
}
}
Gruß JJR