8000 Merge pull request #497 from SethTisue/remove-inappropriate-app-refer… · applideveloper/scala.github.com@abb60a1 · GitHub
[go: up one dir, main page]

Skip to content

Commit abb60a1

Browse files
committed
Merge pull request scala#497 from SethTisue/remove-inappropriate-app-reference
remove inappropriate warning about App
2 parents 4557b79 + d49c738 commit abb60a1

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

tutorials/tour/polymorphic-methods.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,13 @@ Methods in Scala can be parameterized with both values and types. Like on the cl
1515

1616
Here is an example:
1717

18-
object PolyTest extends App {
19-
def dup[T](x: T, n: Int): List[T] =
20-
if (n == 0)
21-
Nil
22-
else
23-
x :: dup(x, n - 1)
18+
def dup[T](x: T, n: Int): List[T] =
19+
if (n == 0)
20+
Nil
21+
else
22+
x :: dup(x, n - 1)
2423

25-
println(dup[Int](3, 4))
26-
println(dup("three", 3))
27-
}
24+
println(dup[Int](3, 4))
25+
println(dup("three", 3))
2826

29-
Method `dup` in object `PolyTest` is parameterized with type `T` and with the value parameters `x: T` and `n: Int`. When method `dup` is called, the programmer provides the required parameters _(see line 8 in the program above)_, but as line 9 in the program above shows, the programmer is not required to give actual type parameters explicitly. The type system of Scala can infer such types. This is done by looking at the types of the given value parameters and at the context where the method is called.
30-
31-
Please note that the trait `App` is designed for writing short test programs, but should be avoided for production code (for Scala versions 2.8.x and earlier) as it may affect the ability of the JVM to optimize the resulting code; please use `def main()` instead.
27+
Method `dup` is parameterized with type `T` and with the value parameters `x: T` and `n: Int`. In the first call to `dup`, the programmer provides the required parameters, but as the following line shows, the programmer is not required to give actual type parameters explicitly. The type system of Scala can infer such types. This is done by looking at the types of the given value parameters and at the context where the method is called.

0 commit comments

Comments
 (0)
0