Skip to content

Commit f434cba

Browse files
committed
Fixes example snippets in StringUTF16View.swift
1 parent 041dfb9 commit f434cba

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

stdlib/public/core/StringUTF16View.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extension String {
5656
///
5757
/// let favemoji = "My favorite emoji is 🎉"
5858
/// if let i = favemoji.utf16.firstIndex(where: { $0 >= 128 }) {
59-
/// let asciiPrefix = String(favemoji.utf16[..<i])
59+
/// let asciiPrefix = String(favemoji.utf16[..<i])!
6060
/// print(asciiPrefix)
6161
/// }
6262
/// // Prints "My favorite emoji is "
@@ -356,7 +356,7 @@ extension String.UTF16View.Index {
356356
/// let stringIndex = cafe.firstIndex(of: "é")!
357357
/// let utf16Index = String.Index(stringIndex, within: cafe.utf16)!
358358
///
359-
/// print(cafe.utf16[...utf16Index])
359+
/// print(String(cafe.utf16[...utf16Index])!)
360360
/// // Prints "Café"
361361
///
362362
/// - Parameters:
@@ -387,7 +387,7 @@ extension String.UTF16View.Index {
387387
/// let cafe = "Café 🍵"
388388
/// let i = cafe.utf16.firstIndex(of: 32)!
389389
/// let j = i.samePosition(in: cafe.unicodeScalars)!
390-
/// print(cafe.unicodeScalars[..<j])
390+
/// print(String(cafe.unicodeScalars[..<j]))
391391
/// // Prints "Café"
392392
///
393393
/// - Parameter unicodeScalars: The view to use for the index conversion.

0 commit comments

Comments
 (0)