Skip to content

Commit

Permalink
Update String.swift.
Browse files Browse the repository at this point in the history
  • Loading branch information
jindulys committed Jul 9, 2017
1 parent a2dca66 commit 72f7c6c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Sources/App/Extensions/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ extension String {
let array = ["sky", "china", "test", "hello", "US",
"procrastinate", "root", "Apple", "iOS",
"machine", "waterloo", "glass", "night"]
srandom(UInt32(time(nil)))
let number = Int(arc4random() % 10)
var ret = ""
for _ in 0..<number {
#if os(Linux)
srandom(UInt32(time(nil)))
let number = Int(random() % 10)
let index = Int(random() % UInt32(array.count))
let count = Int(random() % 6)
#else
let number = Int(arc4random() % 10)
let index = Int(arc4random() % UInt32(array.count))
let count = Int(arc4random() % 6)
#endif
var ret = ""
for _ in 0..<number {
ret += array[index]*count
}
return ret
Expand Down

0 comments on commit 72f7c6c

Please sign in to comment.