Last active
October 21, 2016 05:49
-
-
Save lmatt-bit/1796deacaa67bffb2a3845782c77afdd to your computer and use it in GitHub Desktop.
Scala common actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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