Skip to content

Commit ebfc251

Browse files
authored
Merge pull request #2438 from kazanzhy/fix_typos
2 parents 00934f7 + 4ae6fab commit ebfc251

File tree

89 files changed

+242
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+242
-242
lines changed

_contribute_resources/2-bug-fixes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ title: Bug fixes
33
link: /contribute/guide.html
44
icon: fa fa-bug
55
---
6-
Issues with the tools, core libraries and compiler. Also you can help us by [reporting bugs][bug-reporting-guide].
6+
Issues with the tools, core libraries and compiler. Also, you can help us by [reporting bugs][bug-reporting-guide].
77

88
[bug-reporting-guide]: {% link _overviews/contribute/bug-reporting-guide.md %}

_getting-started/intellij-track/getting-started-with-scala-in-intellij.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ you'll need to install a Scala SDK. To the right of the Scala SDK field,
3434
click the **Create** button.
3535
1. Select the highest version number (e.g. {{ site.scala-version }}) and click **Download**. This might
3636
take a few minutes but subsequent projects can use the same SDK.
37-
1. Once the SDK is created and you're back to the "New Project" window click **Finish**.
37+
1. Once the SDK is created, and you're back to the "New Project" window, click **Finish**.
3838

3939

4040
## Writing code

_getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj
2828
unrecognized.
2929
1. On the project pane on the left, expand `src` => `main`.
3030
1. Right-click on `scala` and select **New** => **Scala class**.
31-
1. Call it `CubeCalculator`, change the **Kind** to `object`, and hit enter or double click on `object`.
31+
1. Call it `CubeCalculator`, change the **Kind** to `object`, and hit enter or double-click on `object`.
3232
1. Replace the code with the following:
3333
```
3434
object CubeCalculator extends App {
@@ -41,7 +41,7 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj
4141
## Creating a test
4242
1. On the project pane on the left, expand `src` => `test`.
4343
1. Right-click on `scala` and select **New** => **Scala class**.
44-
1. Name the class `CubeCalculatorTest` and hit enter or double click on `class`.
44+
1. Name the class `CubeCalculatorTest` and hit enter or double-click on `class`.
4545
1. Replace the code with the following:
4646
```
4747
import org.scalatest.funsuite.AnyFunSuite

_glossary/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ You can assign an object to a variable. Afterwards, the variable will refer to t
4444
Extra constructors defined inside the curly braces of the class definition, which look like method definitions named `this`, but with no result type.
4545

4646
* #### block
47-
One or more expressions and declarations surrounded by curly braces. When the block evaluates, all of its expressions and declarations are processed in order, and then the block returns the value of the last expression as its own value. Blocks are commonly used as the bodies of functions, [for expressions](#for-expression), `while` loops, and any other place where you want to group a number of statements together. More formally, a block is an encapsulation construct for which you can only see side effects and a result value. The curly braces in which you define a class or object do not, therefore, form a block, because fields and methods (which are defined inside those curly braces) are visible from the out- side. Such curly braces form a template.
47+
One or more expressions and declarations surrounded by curly braces. When the block evaluates, all of its expressions and declarations are processed in order, and then the block returns the value of the last expression as its own value. Blocks are commonly used as the bodies of functions, [for expressions](#for-expression), `while` loops, and any other place where you want to group a number of statements together. More formally, a block is an encapsulation construct for which you can only see side effects and a result value. The curly braces in which you define a class or object do not, therefore, form a block, because fields and methods (which are defined inside those curly braces) are visible from the outside. Such curly braces form a template.
4848

4949
* #### bound variable
5050
A bound variable of an expression is a variable that’s both used and defined inside the expression. For instance, in the function literal expression `(x: Int) => (x, y)`, both variables `x` and `y` are used, but only `x` is bound, because it is defined in the expression as an `Int` and the sole argument to the function described by the expression.
@@ -299,7 +299,7 @@ A _self type_ of a trait is the assumed type of `this`, the receiver, to be used
299299
XML data is semi-structured. It is more structured than a flat binary file or text file, but it does not have the full structure of a programming language’s data structures.
300300

301301
* #### serialization
302-
You can _serialize_ an object into a byte stream which can then be saved to files or transmitted over the network. You can later _deserialize_ the byte stream, even on different computer, and obtain an object that is the same as the original serialized object.
302+
You can _serialize_ an object into a byte stream which can then be saved to a file or transmitted over the network. You can later _deserialize_ the byte stream, even on different computer, and obtain an object that is the same as the original serialized object.
303303

304304
* #### shadow
305305
A new declaration of a local variable _shadows_ one of the same name in an enclosing scope.

_overviews/FAQ/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fatal.
8282
opinionated sbt plugin that sets many options automatically, depending
8383
on Scala version; you can see
8484
[here](https://github.com/DavidGregory084/sbt-tpolecat/blob/master/src/main/scala/io/github/davidgregory084/TpolecatPlugin.scala)
85-
what it sets. Some of the choices it makes are oriented towards
85+
what it sets. Some choices it makes are oriented towards
8686
pure-functional programmers.
8787

8888
### How do I find what some symbol means or does?
@@ -205,7 +205,7 @@ So for example, a `List[Int]` in Scala code will appear to Java as a
205205
appear as type parameters, but couldn't they appear as their boxed
206206
equivalents, such as `List[java.lang.Integer]`?
207207

208-
One would hope so, but doing it that way was tried and it proved impossible.
208+
One would hope so, but doing it that way was tried, and it proved impossible.
209209
[This SO question](https://stackoverflow.com/questions/11167430/why-are-primitive-types-such-as-int-erased-to-object-in-scala)
210210
sadly lacks a concise explanation, but it does link to past discussions.
211211

_overviews/FAQ/initialization-order.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Usually the best answer. Unfortunately you cannot declare an abstract lazy val.
9494
2. Declare an abstract def, and hope subclasses will implement it as a lazy val. If they do not, it will be re-evaluated on every access.
9595
3. Declare a concrete lazy val which throws an exception, and hope subclasses override it. If they do not, it will... throw an exception.
9696

97-
An exception during initialization of a lazy val will cause the right hand side to be re-evaluated on the next access: see SLS 5.2.
97+
An exception during initialization of a lazy val will cause the right-hand side to be re-evaluated on the next access: see SLS 5.2.
9898

9999
Note that using multiple lazy vals creates a new risk: cycles among lazy vals can result in a stack overflow on first access.
100100

_overviews/collections-2.13/arrays.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ The `ArrayOps` object gets inserted automatically by the implicit conversion. So
5959
scala> intArrayOps(a1).reverse
6060
res5: Array[Int] = Array(3, 2, 1)
6161

62-
where `intArrayOps` is the implicit conversion that was inserted previously. This raises the question how the compiler picked `intArrayOps` over the other implicit conversion to `ArraySeq` in the line above. After all, both conversions map an array to a type that supports a reverse method, which is what the input specified. The answer to that question is that the two implicit conversions are prioritized. The `ArrayOps` conversion has a higher priority than the `ArraySeq` conversion. The first is defined in the `Predef` object whereas the second is defined in a class `scala.LowPriorityImplicits`, which is inherited by `Predef`. Implicits in subclasses and subobjects take precedence over implicits in base classes. So if both conversions are applicable, the one in `Predef` is chosen. A very similar scheme works for strings.
62+
where `intArrayOps` is the implicit conversion that was inserted previously. This raises the question of how the compiler picked `intArrayOps` over the other implicit conversion to `ArraySeq` in the line above. After all, both conversions map an array to a type that supports a reverse method, which is what the input specified. The answer to that question is that the two implicit conversions are prioritized. The `ArrayOps` conversion has a higher priority than the `ArraySeq` conversion. The first is defined in the `Predef` object whereas the second is defined in a class `scala.LowPriorityImplicits`, which is inherited by `Predef`. Implicits in subclasses and subobjects take precedence over implicits in base classes. So if both conversions are applicable, the one in `Predef` is chosen. A very similar scheme works for strings.
6363

64-
So now you know how arrays can be compatible with sequences and how they can support all sequence operations. What about genericity? In Java you cannot write a `T[]` where `T` is a type parameter. How then is Scala's `Array[T]` represented? In fact a generic array like `Array[T]` could be at run-time any of Java's eight primitive array types `byte[]`, `short[]`, `char[]`, `int[]`, `long[]`, `float[]`, `double[]`, `boolean[]`, or it could be an array of objects. The only common run-time type encompassing all of these types is `AnyRef` (or, equivalently `java.lang.Object`), so that's the type to which the Scala compiler maps `Array[T]`. At run-time, when an element of an array of type `Array[T]` is accessed or updated there is a sequence of type tests that determine the actual array type, followed by the correct array operation on the Java array. These type tests slow down array operations somewhat. You can expect accesses to generic arrays to be three to four times slower than accesses to primitive or object arrays. This means that if you need maximal performance, you should prefer concrete over generic arrays. Representing the generic array type is not enough, however, there must also be a way to create generic arrays. This is an even harder problem, which requires a little bit of help from you. To illustrate the problem, consider the following attempt to write a generic method that creates an array.
64+
So now you know how arrays can be compatible with sequences and how they can support all sequence operations. What about genericity? In Java, you cannot write a `T[]` where `T` is a type parameter. How then is Scala's `Array[T]` represented? In fact a generic array like `Array[T]` could be at run-time any of Java's eight primitive array types `byte[]`, `short[]`, `char[]`, `int[]`, `long[]`, `float[]`, `double[]`, `boolean[]`, or it could be an array of objects. The only common run-time type encompassing all of these types is `AnyRef` (or, equivalently `java.lang.Object`), so that's the type to which the Scala compiler maps `Array[T]`. At run-time, when an element of an array of type `Array[T]` is accessed or updated there is a sequence of type tests that determine the actual array type, followed by the correct array operation on the Java array. These type tests slow down array operations somewhat. You can expect accesses to generic arrays to be three to four times slower than accesses to primitive or object arrays. This means that if you need maximal performance, you should prefer concrete to generic arrays. Representing the generic array type is not enough, however, there must also be a way to create generic arrays. This is an even harder problem, which requires a little of help from you. To illustrate the issue, consider the following attempt to write a generic method that creates an array.
6565

6666
// this is wrong!
6767
def evenElems[T](xs: Vector[T]): Array[T] = {
@@ -71,7 +71,7 @@ So now you know how arrays can be compatible with sequences and how they can sup
7171
arr
7272
}
7373

74-
The `evenElems` method returns a new array that consist of all elements of the argument vector `xs` which are at even positions in the vector. The first line of the body of `evenElems` creates the result array, which has the same element type as the argument. So depending on the actual type parameter for `T`, this could be an `Array[Int]`, or an `Array[Boolean]`, or an array of some of the other primitive types in Java, or an array of some reference type. But these types have all different runtime representations, so how is the Scala runtime going to pick the correct one? In fact, it can't do that based on the information it is given, because the actual type that corresponds to the type parameter `T` is erased at runtime. That's why you will get the following error message if you compile the code above:
74+
The `evenElems` method returns a new array that consist of all elements of the argument vector `xs` which are at even positions in the vector. The first line of the body of `evenElems` creates the result array, which has the same element type as the argument. So depending on the actual type parameter for `T`, this could be an `Array[Int]`, or an `Array[Boolean]`, or an array of some other primitive types in Java, or an array of some reference type. But these types have all different runtime representations, so how is the Scala runtime going to pick the correct one? In fact, it can't do that based on the information it is given, because the actual type that corresponds to the type parameter `T` is erased at runtime. That's why you will get the following error message if you compile the code above:
7575

7676
error: cannot find class manifest for element type T
7777
val arr = new Array[T]((arr.length + 1) / 2)

_overviews/collections-2.13/concrete-immutable-collection-classes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ the original array’s elements.
8484
## Vectors
8585

8686
We have seen in the previous sections that `List` and `ArraySeq` are efficient data structures in some specific
87-
use cases but they are also inefficient in other use cases: for instance, prepending an element is constant for `List`,
87+
use cases, but they are also inefficient in other use cases: for instance, prepending an element is constant for `List`,
8888
but linear for `ArraySeq`, and, conversely, indexed access is constant for `ArraySeq` but linear for `List`.
8989

9090
[Vector](https://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/immutable/Vector.html) is a collection type that provides good performance for all its operations. Vectors allow accessing any element of the sequence in "effectively" constant time. It's a larger constant than for access to the head of a List or for reading an element of an ArraySeq, but it's a constant nonetheless. As a result, algorithms using vectors do not have to be careful about accessing just the head of the sequence. They can access and modify elements at arbitrary locations, and thus they can be much more convenient to write.

_overviews/collections-2.13/concrete-mutable-collection-classes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ It is supported by class [mutable.Stack](https://www.scala-lang.org/api/{{ site.
107107

108108
Array sequences are mutable sequences of fixed size which store their elements internally in an `Array[Object]`. They are implemented in Scala by class [ArraySeq](https://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/mutable/ArraySeq.html).
109109

110-
You would typically use an `ArraySeq` if you want an array for its performance characteristics, but you also want to create generic instances of the sequence where you do not know the type of the elements and you do not have a `ClassTag` to provide it at run-time. These issues are explained in the section on [arrays]({% link _overviews/collections-2.13/arrays.md %}).
110+
You would typically use an `ArraySeq` if you want an array for its performance characteristics, but you also want to create generic instances of the sequence where you do not know the type of the elements, and you do not have a `ClassTag` to provide it at run-time. These issues are explained in the section on [arrays]({% link _overviews/collections-2.13/arrays.md %}).
111111

112112
## Hash Tables
113113

_overviews/collections-2.13/creating-collections-from-scratch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Besides `apply`, every collection companion object also defines a member `empty`
4141
The operations provided by collection companion objects are summarized in the following table. In short, there's
4242

4343
* `concat`, which concatenates an arbitrary number of collections together,
44-
* `fill` and `tabulate`, which generate single or multi-dimensional collections of given dimensions initialized by some expression or tabulating function,
44+
* `fill` and `tabulate`, which generate single or multidimensional collections of given dimensions initialized by some expression or tabulating function,
4545
* `range`, which generates integer collections with some constant step length, and
4646
* `iterate` and `unfold`, which generates the collection resulting from repeated application of a function to a start element or state.
4747

_overviews/collections-2.13/equality.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ permalink: /overviews/collections-2.13/:title.html
1414

1515
The collection libraries have a uniform approach to equality and hashing. The idea is, first, to divide collections into sets, maps, and sequences. Collections in different categories are always unequal. For instance, `Set(1, 2, 3)` is unequal to `List(1, 2, 3)` even though they contain the same elements. On the other hand, within the same category, collections are equal if and only if they have the same elements (for sequences: the same elements in the same order). For example, `List(1, 2, 3) == Vector(1, 2, 3)`, and `HashSet(1, 2) == TreeSet(2, 1)`.
1616

17-
It does not matter for the equality check whether a collection is mutable or immutable. For a mutable collection one simply considers its current elements at the time the equality test is performed. This means that a mutable collection might be equal to different collections at different times, depending what elements are added or removed. This is a potential trap when using a mutable collection as a key in a hashmap. Example:
17+
It does not matter for the equality check whether a collection is mutable or immutable. For a mutable collection one simply considers its current elements at the time the equality test is performed. This means that a mutable collection might be equal to different collections at different times, depending on what elements are added or removed. This is a potential trap when using a mutable collection as a key in a hashmap. Example:
1818

1919
scala> import collection.mutable.{HashMap, ArrayBuffer}
2020
import collection.mutable.{HashMap, ArrayBuffer}

_overviews/collections-2.13/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ lines run at first try.
4848

4949
**Fast:** Collection operations are tuned and optimized in the
5050
libraries. As a result, using collections is typically quite
51-
efficient. You might be able to do a little bit better with carefully
51+
efficient. You might be able to do a little better with carefully
5252
hand-tuned data structures and operations, but you might also do a lot
5353
worse by making some suboptimal implementation decisions along the
5454
way.

_overviews/collections-2.13/iterators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ A lazy operation does not immediately compute all of its results. Instead, it co
170170

171171
So the expression `(1 to 10).iterator.map(println)` would not print anything to the screen. The `map` method in this case doesn't apply its argument function to the values in the range, it returns a new `Iterator` that will do this as each one is requested. Adding `.toList` to the end of that expression will actually print the elements.
172172

173-
A consequence of this is that a method like `map` or `filter` won't necessarily apply its argument function to all of the input elements. The expression `(1 to 10).iterator.map(println).take(5).toList` would only print the values `1` to `5`, for instance, since those are only ones that will be requested from the `Iterator` returned by `map`.
173+
A consequence of this is that a method like `map` or `filter` won't necessarily apply its argument function to all the input elements. The expression `(1 to 10).iterator.map(println).take(5).toList` would only print the values `1` to `5`, for instance, since those are only ones that will be requested from the `Iterator` returned by `map`.
174174

175175
This is one of the reasons why it's important to only use pure functions as arguments to `map`, `filter`, `fold` and similar methods. Remember, a pure function has no side-effects, so one would not normally use `println` in a `map`. `println` is used to demonstrate laziness as it's not normally visible with pure functions.
176176

0 commit comments

Comments
 (0)