3 ms·
There are a number of syntactic errors and typos in the article. For instance `sum` should be: * def sum(x: Int, y: Int) = x + y Why `return x * y`? That is n
by jlh276 14y ago
There are a number of syntactic errors and typos in the article. For instance `sum` should be:
* def sum(x: Int, y: Int) = x + y
Why `return x * y`? That is not a sum... Also using `return` is not idiomatic scala.
* List(1, 2, 3) ::: List(4, 5, 6)
That is the more typical way to concatenate lists. Using `+` will actually fail to compile.
* list.map(i => i + 1)
to increment the list. forall checks that a predicate is true for all elements.
And so on...
- grdvnl 14y agoThanks, fixed the errors.
- polymatter 14y agoI still see under the heading 'Choose between explicit type declaration or implicit type inference' the following: > Sum(x: Integer, u: Integer): Int = return x * y > or > Sum(x: Integer, u: Integer): = return x * y Clearly, x * y is not the sum. And y isn't in the argument list, u is. And in both cases the return statement is unnecessary and should be omitted.