Skip to content

Commit 4cf5613

Browse files
committed
Merge pull request #2460 from dakeshi/stdlib-core-array-structure
[stdlib] Fix print method syntax and add the optional binding
2 parents 14a7334 + b49b5c4 commit 4cf5613

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

stdlib/public/core/Arrays.swift.gyb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,12 @@ if True:
229229
/// array's first and last elements. If the array is empty, these properties
230230
/// are `nil`.
231231
///
232-
/// print(oddNumbers.first, oddNumbers.last, separator=", ")
232+
/// if let firstElement = oddNumbers.first, lastElement = oddNumbers.last {
233+
/// print(firstElement, lastElement, separator: ", ")
234+
/// }
233235
/// // Prints "1, 15"
234236
///
235-
/// print(emptyDoubles.first, emptyDoubles.last, separator=", ")
237+
/// print(emptyDoubles.first, emptyDoubles.last, separator: ", ")
236238
/// // Prints "nil, nil"
237239
///
238240
/// You can access individual array elements through a subscript. The first
@@ -241,7 +243,7 @@ if True:
241243
/// the count of the array. Using a negative number or an index equal to or
242244
/// greater than `count` triggers a runtime error. For example:
243245
///
244-
/// print(oddNumbers[0], oddNumbers[3], separator=", ")
246+
/// print(oddNumbers[0], oddNumbers[3], separator: ", ")
245247
/// // Prints "1, 7"
246248
///
247249
/// print(emptyDoubles[0])

0 commit comments

Comments
 (0)