Skip to content

Commit d3819ea

Browse files
committed
Adjust phrasing
I think pointing out [Int]() from the code example is easier to follow than [Element](), since the reader doesn't have to mentally map or substitute a placeholder. Reserve emphasis around new terms for when they're being introduced and also explicitly defined. No need to call out the book's style in the book itself.
1 parent bd2914f commit d3819ea

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

TSPL.docc/LanguageGuide/CollectionTypes.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ and is used throughout this guide when referring to the type of an array.
7070

7171
### Creating an Empty Array
7272

73-
You can create an empty array in Swift using one of two approaches:
73+
You can create an empty array in Swift using two approaches,
74+
as shown in the following examples.
7475

7576
If the context already provides type information,
7677
such as a function argument or an already typed variable or constant,
77-
you can create an empty array with an *empty array literal*,
78+
you can use an empty array literal,
7879
which is written as `[]`
7980
(an empty pair of square brackets):
8081

@@ -95,9 +96,10 @@ print("someInts is of type [Int] with \(someInts.count) items.")
9596
-->
9697

9798
Alternatively, you can create an empty array of a certain type
98-
using *initializer syntax*,
99-
which is done by writing the type in square brackets
100-
followed by parentheses (`[Element]()`):
99+
using explicit initializer syntax,
100+
by writing the element type in square brackets
101+
followed by parentheses ---
102+
for example, `[Int]()` in the following:
101103

102104
```swift
103105
var someInts = [Int]()
@@ -106,9 +108,8 @@ print("someInts is of type [Int] with \(someInts.count) items.")
106108
```
107109

108110
Both approaches produce the same result.
109-
However, the empty array literal (`[]`) is the preferred way to
110-
initialize an empty array because it is more concise and aligns with
111-
the style guidelines used throughout this guide.
111+
However,
112+
an empty array literal is shorter and usually easier to read.
112113

113114
In both cases, you can use the empty array literal (`[]`) to
114115
reassign an empty array to an existing variable:

0 commit comments

Comments
 (0)