You can create a String extension like so:
extension String { func someFunc -> Bool { ... } }
but what if you want it to apply to opt
extension Optional where Wrapped == String { var isNil: Bool { return self == nil }
The above answer(written by @Vlad Hatko) works fine but in swift 4 there are some issues, so I changed it to this.