Created
July 7, 2015 14:57
-
-
Save digvijaybhakuni/e6cdd87ff39c80dc2216 to your computer and use it in GitHub Desktop.
Test Scala Scripting
This file contains 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
println("Hello, World!") | |
println(args!=null) | |
println(args) | |
for{i <- 0 to args.length - 1 } | |
println(" args %d index value is %s ".format(i,args(i))) | |
//There are three string insterpolation method out of the box s, f and raw | |
//Using s String Interpolator | |
val name = "Ashish" | |
println(s"$name mera bagal m betha hai") | |
println(s" 1 + 1 kitna hota hai ${ 1 + 1} hota hai") | |
//Using f Interpolator (its like formating with s Interpolator like printf) and it typesafe and if there is no % char that mean it is %s by default | |
val height:Double = 100.9d | |
println(f"Hight of $name%s is $height%02.5f meters ") | |
val testInt:Int = 10000000 | |
println(f" Int test $testInt%4d ") | |
//Using raw Interpolator | |
println(raw" First Line \n Second Line ") | |
import java.util._ | |
val date:Date = new Date("10/04/1990") | |
date setHours 16 | |
date setMinutes 30 | |
val sdate:String = date.toString | |
println(sdate) | |
implicit class JsonHelper(val sc: StringContext) extends AnyVal { | |
def json(args: Any*): JSONObject = sys.error("TODO - IMPLEMENT") | |
} | |
def giveMeSomeJson(x: JSONObject) : { println "Hello JSON"+x } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment