Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apparaomulpuri/readline
Explains you the usage of readLine function in Swift.
https://github.com/apparaomulpuri/readline
data fromkeyboard keyboard reading readline swift
Last synced: 17 days ago
JSON representation
Explains you the usage of readLine function in Swift.
- Host: GitHub
- URL: https://github.com/apparaomulpuri/readline
- Owner: ApparaoMulpuri
- License: mit
- Created: 2017-12-15T06:13:48.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-15T08:43:27.000Z (about 7 years ago)
- Last Synced: 2023-12-08T15:18:01.953Z (about 1 year ago)
- Topics: data, fromkeyboard, keyboard, reading, readline, swift
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# readLine
Explains you how to use the **readLine** function in Swift.1. #### Reading data from the Keyboard in Swift
```
let input = readLine()
if let input = input {
print(input) //Input will be printed out
}
```2. #### Reading Int from the keyboard
```
let input = Int(readLine()!)
if let input = input {
print(input) //Input integer will be printed out.
}
```3. #### Reading String from the keyboard
```
let input = String(readLine()!)
if let input = input {
print(input) //Input Stirng will be printed out.
}
```4. #### Reading data from the keyboard and convert that into an Array
```
let input = readLine()
if let input = input {
let numbersFromKeyboard = input.split(separator: " ")
let numbers = numbersFromKeyboard.map { Int(String($0))! }
print(numbers)
}
```