Skip to content

Instantly share code, notes, and snippets.

@milessabin
Created April 23, 2012 19:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milessabin/2473113 to your computer and use it in GitHub Desktop.
Save milessabin/2473113 to your computer and use it in GitHub Desktop.
Default argument values only need to typecheck if they're needed.
scala> implicit val i = 23
i: Int = 23
scala> def foo[T](t : T)(implicit ev : T = "foo") = ev
foo: [T](t: T)(implicit ev: T)T
scala> foo(0)
res6: Int = 23
scala> foo("bar")
res7: java.lang.String = foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment