Skip to content

Commit b22aa06

Browse files
authored
Minor grammar fixes in polymorphic methods section (#2577)
1 parent 2bb286b commit b22aa06

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

_tour/polymorphic-methods.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ prerequisite-knowledge: unified-types
1212
redirect_from: "/tutorials/tour/polymorphic-methods.html"
1313
---
1414

15-
Methods in Scala can be parameterized by type as well as value. The syntax is similar to that of generic classes. Type parameters are enclosed in square brackets, while value parameters are enclosed in parentheses.
15+
Methods in Scala can be parameterized by type as well as by value. The syntax is similar to that of generic classes. Type parameters are enclosed in square brackets, while value parameters are enclosed in parentheses.
1616

1717
Here is an example:
1818

@@ -45,6 +45,6 @@ println(listOfDuplicates("La", 8)) // List(La, La, La, La, La, La, La, La)
4545

4646
The method `listOfDuplicates` takes a type parameter `A` and value parameters `x` and `length`. Value `x` is of type `A`. If `length < 1` we return an empty list. Otherwise we prepend `x` to the list of duplicates returned by the recursive call. (Note that `::` means prepend an element on the left to a list on the right.)
4747

48-
In first example call, we explicitly provide the type parameter by writing `[Int]`. Therefore the first argument must be an `Int` and the return type will be `List[Int]`.
48+
In the first example call, we explicitly provide the type parameter by writing `[Int]`. Therefore the first argument must be an `Int` and the return type will be a `List[Int]`.
4949

50-
The second example call shows that you don't always need to explicitly provide the type parameter. The compiler can often infer it based on context or on the types of the value arguments. In this example, `"La"` is a `String` so the compiler knows `A` must be `String`.
50+
The second example call shows that you don't always need to explicitly provide the type parameter. The compiler can often infer it based on context or on the types of the value arguments. In this example, `"La"` is a `String` so the compiler knows that `A` must be a `String`.

0 commit comments

Comments
 (0)