Created
October 7, 2015 10:05
-
-
Save jamesanto/5e1ff291605b1b5f682a to your computer and use it in GitHub Desktop.
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
package imp | |
/** | |
* Created by jamesanto on 10/7/15. | |
*/ | |
object imps { | |
implicit val prefix: String = "Hello " | |
//implicit val tt: String = "Text" | |
implicit def doubleToInt(d: Double):Int = d.toInt | |
implicit class RichString(s: String) { | |
def hasVal = s != null && !s.trim.isEmpty | |
} | |
} | |
object ImpTest { | |
import imps._ | |
def printMe(name: String)(implicit prefix: String) = { | |
println(prefix + name) | |
} | |
def main(args: Array[String]) { | |
printMe("JJ") | |
val a: Int = 10.5 | |
println(s" A = $a") | |
val s1: String = null | |
println(s1.hasVal) | |
val s2 = " " | |
println(s2.hasVal) | |
val s3 = "fdaf" | |
println(s3.hasVal) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment