Guest User

Untitled

a guest
Apr 30th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. scala> :paste
  2. class :=[T,Q]
  3. trait Default_:={
  4. /** Ignore default */
  5. implicit def useProvided[Provided,Default] = new :=[Provided,Default]
  6. }
  7. object := extends Default_:={
  8. /** Infer type argument to default */
  9. implicit def useDefault[Default] = new :=[Default,Default]
  10. }
  11.  
  12. scala> def foo[T](implicit default: T := Int, ct: reflect.ClassTag[T]) = ct.toString
  13. scala> foo
  14. res0: String = Int
  15. scala> foo[String]
  16. res1: String = java.lang.String
Advertisement
Add Comment
Please, Sign In to add comment