Skip to content

Instantly share code, notes, and snippets.

@jamesanto
Created October 7, 2015 10:05
Show Gist options
  • Save jamesanto/5e1ff291605b1b5f682a to your computer and use it in GitHub Desktop.
Save jamesanto/5e1ff291605b1b5f682a to your computer and use it in GitHub Desktop.
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