Skip to content

Commit b7db284

Browse files
authored
Merge pull request #796 from MaxNevermind/MaxNevermind-patch-1
fixes typo in Polymorphic Methods post
2 parents 6fd94f3 + 58139b5 commit b7db284

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tutorials/tour/_posts/2017-02-13-polymorphic-methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ println(listOfDuplicates[Int](3, 4)) // List(3, 3, 3, 3)
2929
println(listOfDuplicates("La", 8)) // List(La, La, La, La, La, La, La, La)
3030
```
3131

32-
The method `listOfDuplicates` takes a type parameter `A` and values parameters `x` and `n`. In this case, value `x` is of type `A`. If `length > 1` we return an empty list. Otherwise we prepend `x` to the the list of duplicates returned by the recursive call to `listOfDuplicates`. (note: `::` means prepend an element on the left to a sequence on the right).
32+
The method `listOfDuplicates` takes a type parameter `A` and values parameters `x` and `n`. In this case, value `x` is of type `A`. If `length < 1` we return an empty list. Otherwise we prepend `x` to the the list of duplicates returned by the recursive call to `listOfDuplicates`. (note: `::` means prepend an element on the left to a sequence on the right).
3333

3434
When we call `listOfDuplicates` with `[Int]` as the type parameter, the first argument must be an int and the return type will be List[Int]. However, you don't always need to explicitly provide the the type parameter because the compiler can often figure it out based on the type of value argument (`"La"` is a String). In fact, if calling this method from Java it is impossible to provide the type parameter.

0 commit comments

Comments
 (0)