diff options
author | Daniel C. Sobral <dcsobral@gmail.com> | 2012-01-13 14:57:32 -0200 |
---|---|---|
committer | Daniel C. Sobral <dcsobral@gmail.com> | 2012-01-13 15:10:39 -0200 |
commit | 545680b2746cc0c7ae658f6c66e68e763b0b58c9 (patch) | |
tree | a5f1e66a618b638766db0c170621210c3cfc1b3f /src/library/scala/Function1.scala | |
parent | b0de5f13329aa24752fae079c50cc0584471379e (diff) | |
download | scala-545680b2746cc0c7ae658f6c66e68e763b0b58c9.tar.gz scala-545680b2746cc0c7ae658f6c66e68e763b0b58c9.tar.bz2 scala-545680b2746cc0c7ae658f6c66e68e763b0b58c9.zip |
Explain Function1 vs PartialFunction
Add an explanation in PartialFunction as to how it differs from Function1,
with examples of what it can do that Function1 cannot.
Make it explicit that calling apply may throw exceptions in both of them,
even in the case where isDefinedAt returns true.
Closes SI-5370.
Diffstat (limited to 'src/library/scala/Function1.scala')
-rw-r--r-- | src/library/scala/Function1.scala | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/library/scala/Function1.scala b/src/library/scala/Function1.scala index dc8e67bbb0..7517e6604b 100644 --- a/src/library/scala/Function1.scala +++ b/src/library/scala/Function1.scala @@ -24,10 +24,18 @@ package scala * assert(succ(0) == anonfun1(0)) * } * }}} + * + * Note that `Function1` does not define a total function, as might + * be suggested by the existence of [[scala.PartialFunction]]. The only + * distinction between `Function1` and `PartialFunction` is that the + * latter can specify inputs which it will not handle. + * */ @annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.") trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double) +R] extends AnyRef { self => - /** Apply the body of this function to the argument. + /** Apply the body of this function to the argument. It may throw an + * exception. + * * @return the result of function application. */ def apply(v1: T1): R |