Skip to content

Commit bb9a41e

Browse files
authored
Merge pull request #31405 from valeriyvan/FixSnippetsCharacterProperties
Fixes example snippets in CharacterProperties.swift
2 parents 3ef7011 + 1ef6001 commit bb9a41e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

stdlib/public/core/CharacterProperties.swift

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ extension Character {
3232
///
3333
/// let chars: [Character] = ["a", " ", "™"]
3434
/// for ch in chars {
35-
/// print(ch, "-->", ch.properties.numericValue)
35+
/// print(ch, "-->", ch.asciiValue)
3636
/// }
37-
/// // a --> 97
38-
/// // --> 32
37+
/// // Prints:
38+
/// // a --> Optional(97)
39+
/// // --> Optional(32)
3940
/// // ™ --> nil
4041
///
4142
/// A character with the value "\r\n" (CR-LF) is normalized to "\n" (LF) and
@@ -125,11 +126,12 @@ extension Character {
125126
///
126127
/// let chars: [Character] = ["4", "④", "万", "a"]
127128
/// for ch in chars {
128-
/// print(ch, "-->", ch.properties.numericValue)
129+
/// print(ch, "-->", ch.wholeNumberValue)
129130
/// }
130-
/// // 4 --> 4
131-
/// // ④ --> 4
132-
/// // 万 --> 10000
131+
/// // Prints:
132+
/// // 4 --> Optional(4)
133+
/// // ④ --> Optional(4)
134+
/// // 万 --> Optional(10000)
133135
/// // a --> nil
134136
public var wholeNumberValue: Int? {
135137
guard _isSingleScalar else { return nil }
@@ -158,9 +160,10 @@ extension Character {
158160
/// for ch in chars {
159161
/// print(ch, "-->", ch.hexDigitValue)
160162
/// }
161-
/// // 1 --> 1
162-
/// // a --> 10
163-
/// // F --> 15
163+
/// // Prints:
164+
/// // 1 --> Optional(1)
165+
/// // a --> Optional(10)
166+
/// // F --> Optional(15)
164167
/// // g --> nil
165168
public var hexDigitValue: Int? {
166169
guard _isSingleScalar else { return nil }
@@ -206,6 +209,7 @@ extension Character {
206209
/// for ch in chars {
207210
/// print(ch, "-->", ch.uppercased())
208211
/// }
212+
/// // Prints:
209213
/// // e --> E
210214
/// // é --> É
211215
/// // и --> И
@@ -223,6 +227,7 @@ extension Character {
223227
/// for ch in chars {
224228
/// print(ch, "-->", ch.lowercased())
225229
/// }
230+
/// // Prints:
226231
/// // E --> e
227232
/// // É --> é
228233
/// // И --> и

0 commit comments

Comments
 (0)