1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 15:25:14 +03:00
vimr/VimR/SwiftCommons.swift

21 lines
534 B
Swift

/**
* 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]
}
}