@@ -102,7 +102,7 @@ extension FixedWidthInteger {
102
102
///
103
103
/// The string passed as `text` may begin with a plus or minus sign character
104
104
/// (`+` or `-`), followed by one or more numeric digits (`0-9`) or letters
105
- /// (`a-z` or `A-Z`). The string is case insensitive.
105
+ /// (`a-z` or `A-Z`). Parsing of the string is case insensitive.
106
106
///
107
107
/// let x = Int("123")
108
108
/// // x == 123
@@ -116,7 +116,7 @@ extension FixedWidthInteger {
116
116
/// // z == 123
117
117
///
118
118
/// If `text` is in an invalid format or contains characters that are out of
119
- /// range for the given `radix`, or if the value it denotes in the given
119
+ /// bounds for the given `radix`, or if the value it denotes in the given
120
120
/// `radix` is not representable, the result is `nil`. For example, the
121
121
/// following conversions result in `nil`:
122
122
///
@@ -155,4 +155,28 @@ extension FixedWidthInteger {
155
155
guard _fastPath ( result != nil ) else { return nil }
156
156
self = result!
157
157
}
158
+
159
+ /// Creates a new integer value from the given string.
160
+ ///
161
+ /// The string passed as `description` may begin with a plus or minus sign
162
+ /// character (`+` or `-`), followed by one or more numeric digits (`0-9`).
163
+ ///
164
+ /// let x = Int("123")
165
+ /// // x == 123
166
+ ///
167
+ /// If `description` is in an invalid format, or if the value it denotes in
168
+ /// base 10 is not representable, the result is `nil`. For example, the
169
+ /// following conversions result in `nil`:
170
+ ///
171
+ /// Int(" 100") // Includes whitespace
172
+ /// Int("21-50") // Invalid format
173
+ /// Int("ff6600") // Characters out of bounds
174
+ /// Int("10000000000000000000000000") // Out of range
175
+ ///
176
+ /// - Parameter description: The ASCII representation of a number.
177
+ @_semantics ( " optimize.sil.specialize.generic.partial.never " )
178
+ @inline ( __always)
179
+ public init ? ( _ description: String ) {
180
+ self . init ( description, radix: 10 )
181
+ }
158
182
}
0 commit comments