1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 03:25:03 +03:00
vimr/VimR/SwiftCommons.swift

21 lines
534 B
Swift
Raw Normal View History

2016-08-14 22:46:03 +03:00
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
func call(@autoclosure closure: () -> Void, when condition: Bool) { if condition { closure() } }
func call(@autoclosure closure: () -> Void, whenNot condition: Bool) { if !condition { closure() } }
extension String {
func without(prefix prefix: String) -> String {
guard self.hasPrefix(prefix) else {
return self
}
let idx = self.startIndex.advancedBy(prefix.characters.count)
return self[idx..<self.endIndex]
}
}