Skip to content

Instantly share code, notes, and snippets.

@lmatt-bit
Last active October 21, 2016 05:49
Show Gist options
  • Select an option

  • Save lmatt-bit/1796deacaa67bffb2a3845782c77afdd to your computer and use it in GitHub Desktop.

Select an option

Save lmatt-bit/1796deacaa67bffb2a3845782c77afdd to your computer and use it in GitHub Desktop.
Scala common actions
// Read output from process' cosole
def getOriginalSentences(more_params: String): Seq[String] = {
val pb = Process("python", Array("test.py",more_params))
pb.lineStream
}
// Cast
val a_int = 1
a_int.asInstanceOf[java.lang.Integer]
// variable string list
val ids = mutable.Buffer[String]()
ids.append("id")
//loop
for(i <- Array(1, 2, 3) ) {
println(i)
}
for(i <- 1 to 3) {
println(i)
}
//Argument
def main(args:Array[String]):Unit = {
//start with 0
if (args.length < 2) {
println("usage: java -jar test.jar zero one")
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment