# Give Int an initializer that takes a single Character

**URL:** <https://forums.swift.org/t/give-int-an-initializer-that-takes-a-single-character/10346>\
**Category:** Pitches\
**Tags:** string\
**Created:** [February 26, 2018, 7:14pm UTC](https://forums.swift.org/t/give-int-an-initializer-that-takes-a-single-character/10346 "2018-02-26T19:14:31Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![cukr](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/cukr/32/889_2.png) [@cukr](https://forums.swift.org/u/cukr)\
**Post date:** [March 15, 2020, 2:08pm UTC](https://forums.swift.org/t/give-int-an-initializer-that-takes-a-single-character/10346/18 "2020-03-15T14:08:29Z")

</div>

Oh, and by the way, you don't have to use map twice, this will work

```swift
let chars: [Character] = ["4", "④", "万", "a"]
let numbers = chars.compactMap(\.wholeNumberValue)
print(numbers) // [4, 4, 10000]
let numbersAndNils = chars.map(\.wholeNumberValue)
print(numbersAndNils) // [Optional(4), Optional(4), Optional(10000), nil]

```

---

_[View the full topic](https://forums.swift.org/t/give-int-an-initializer-that-takes-a-single-character/10346)._
