diff options
author | michelou <michelou@epfl.ch> | 2006-09-27 12:00:16 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2006-09-27 12:00:16 +0000 |
commit | 8d98363504373fbb30360cdf734e8f8f001b8def (patch) | |
tree | e0b4b718cc2e5acdce4b3568fc23faddec89bc74 /src/library/scala/Function2.scala | |
parent | 9643a7ddc29a88ef0644a6543b1632255457d356 (diff) | |
download | scala-8d98363504373fbb30360cdf734e8f8f001b8def.tar.gz scala-8d98363504373fbb30360cdf734e8f8f001b8def.tar.bz2 scala-8d98363504373fbb30360cdf734e8f8f001b8def.zip |
added code example to Scala comment in scala/Fu...
added code example to Scala comment in scala/Function<i>.scala
Diffstat (limited to 'src/library/scala/Function2.scala')
-rw-r--r-- | src/library/scala/Function2.scala | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/library/scala/Function2.scala b/src/library/scala/Function2.scala index 422235f387..be23a05716 100644 --- a/src/library/scala/Function2.scala +++ b/src/library/scala/Function2.scala @@ -13,7 +13,21 @@ package scala /** - * Function with 2 parameters + * Function with 2 parameters. In the following example the definition of + * <code>max</code> is a shorthand for the anonymous class definition + * <code>anonfun2</code>: + * <pre> + * <b>object</b> Main <b>extends</b> Application { + * + * <b>val</b> max = (x: Int, y: Int) => <b>if</b> (x < y) y <b>else</b> x + * + * <b>val</b> anonfun2 = <b>new</b> Function2[Int, Int, Int] { + * <b>def</b> apply(x: Int, y: Int): Int = <b>if</b> (x < y) y <b>else</b> x + * } + * + * Console.println(max(0, 1)) + * Console.println(anonfun2(0, 1)) + * }</pre> */ trait Function2[-T0, -T1, +R] extends AnyRef { def apply(v0: T0, v1: T1): R |