26 lines
548 B
Swift
26 lines
548 B
Swift
import Foundation
|
|
|
|
extension Scanner {
|
|
@discardableResult
|
|
func string(_ string: String) -> Bool {
|
|
return scanString(string) != nil
|
|
}
|
|
|
|
func integers() -> [Int]? {
|
|
var numbers: [Int] = []
|
|
while !isAtEnd {
|
|
guard let num = scanInt() else { return nil }
|
|
numbers.append(num)
|
|
}
|
|
return numbers
|
|
}
|
|
}
|
|
|
|
|
|
extension String {
|
|
func lines() -> [String] {
|
|
var result: [String] = []
|
|
enumerateLines { line, _ in result.append(line) }
|
|
return result
|
|
}
|
|
}
|