You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Grammar: change "object's" to "an object's" and add commas
Also change "parameterized" to "parameterised" to follow the
British spelling convention used elsewhere.
* Format `map` as code
* Grammar: add missing coordinating conjunction "but"
* Grammar: add comma after phrase to avoid semantic ambiguity
* Remove comma splice and reword sentences to enhance clarity
* Grammar: remove comma splices
* Reword sentences to enhance clarity
Copy file name to clipboardExpand all lines: _tour/higher-order-functions.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ The terminology can get a bit confusing at this point, and we use the phrase
16
16
"higher order function" for both methods and functions that take functions as parameters
17
17
or that return a function.
18
18
19
-
In a pure Object Oriented world a good practice is to avoid exposing methods parameterized with functions that might leak object's internal state. Leaking internal state might break the invariants of the object itself thus violating encapsulation.
19
+
In a pure Object Oriented world, a good practice is to avoid exposing methods parameterised with functions that might leak an object's internal state. Leaking internal state might break the invariants of the object itself, thus violating encapsulation.
20
20
21
21
One of the most common examples is the higher-order
22
22
function `map` which is available for collections in Scala.
@@ -51,7 +51,7 @@ val newSalaries = salaries.map(x => x * 2) // List(40000, 140000, 80000)
51
51
{% endtabs %}
52
52
53
53
Notice how `x` is not declared as an Int in the above example. That's because the
54
-
compiler can infer the type based on the type of function map expects (see [Currying](/tour/multiple-parameter-lists.html)). An even more idiomatic way to write the same piece of code would be:
54
+
compiler can infer the type based on the type of function `map` expects (see [Currying](/tour/multiple-parameter-lists.html)). An even more idiomatic way to write the same piece of code would be:
55
55
56
56
{% tabs map_example_3 %}
57
57
@@ -187,7 +187,7 @@ object SalaryRaiser:
187
187
The new method, `promotion`, takes the salaries plus a function of type `Double => Double`
188
188
(i.e. a function that takes a Double and returns a Double) and returns the product.
189
189
190
-
Methods and functions usually express behaviours or data transformations, therefore having functions that compose based on other functions can help building generic mechanisms. Those generic operations defer to lock down the entire operation behaviour giving clients a way to control or further customize parts of the operation itself.
190
+
Methods and functions usually express behaviours or data transformations. Therefore, having functions that compose based on other functions can allow us to build more generic mechanisms. Such generic operations avoid completely locking down their behaviour in order to give clients a way to control or further customize parts of those operations.
Copy file name to clipboardExpand all lines: _tour/tour-of-scala.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ Scala is a modern multi-paradigm programming language designed to express common
28
28
Scala is a pure object-oriented language in the sense that [every value is an object](unified-types.html). Types and behaviors of objects are described by [classes](classes.html) and [traits](traits.html). Classes can be extended by subclassing, and by using a flexible [mixin-based composition](mixin-class-composition.html) mechanism as a clean replacement for multiple inheritance.
29
29
30
30
## Scala is functional ##
31
-
Scala is also a functional language in the sense that [every function is a value](unified-types.html). Scala provides a [lightweight syntax](basics.html#functions) for defining anonymous functions, it supports [higher-order functions](higher-order-functions.html), it allows functions to be [nested](nested-functions.html), and it supports [currying](multiple-parameter-lists.html). Scala's [case classes](case-classes.html) and its built-in support for [pattern matching](pattern-matching.html) provide the functionality of algebraic types, which are used in many functional languages. [Singleton objects](singleton-objects.html) provide a convenient way to group functions that aren't members of a class.
31
+
Scala is also a functional language in the sense that [every function is a value](unified-types.html). Scala provides a [lightweight syntax](basics.html#functions) for defining anonymous functions, supports [higher-order functions](higher-order-functions.html), allows functions to be [nested](nested-functions.html), and supports [currying](multiple-parameter-lists.html). Scala's [case classes](case-classes.html) and its built-in support for [pattern matching](pattern-matching.html) provide the functionality of algebraic types, which are used in many functional languages. [Singleton objects](singleton-objects.html) provide a convenient way to group functions that aren't members of a class.
32
32
33
33
Furthermore, Scala's notion of pattern matching naturally extends to the [processing of XML data](https://github.com/scala/scala-xml/wiki/XML-Processing) with the help of [right-ignoring sequence patterns](regular-expression-patterns.html), by way of general extension via [extractor objects](extractor-objects.html). In this context, [for comprehensions](for-comprehensions.html) are useful for formulating queries. These features make Scala ideal for developing applications like web services.
Copy file name to clipboardExpand all lines: _tour/variances.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -112,7 +112,7 @@ From this, we have to conclude that `Box[Cat]` and `Box[Animal]` can't have a su
112
112
113
113
The problem we ran in to above, is that because we could put a Dog in an Animal Box, a Cat Box can't be an Animal Box.
114
114
115
-
But what if we couldn't put a Dog in the box? Then we could just get our Cat back out and that's not a problem, so than it could follow the subtyping relationship. It turns out, that's indeed something we can do.
115
+
But what if we couldn't put a Dog in the box? Then, we could just get our Cat back out without a problem, and it would adhere to the subtyping relationship. It turns out that that's possible to do.
0 commit comments