3 ms·
You can add your own operator overloading of different number types to mitigate the casting required see: https://github.com/jquave/EasyCast https://github.com/
by mythz 12y ago
You can add your own operator overloading of different number types to mitigate the casting required see:
https://github.com/jquave/EasyCast https://github.com/jquave/EasyCast
You can also add your own String extension for length and index character at in a String with:
extension String {
var length: Int { return countElements(self) }
subscript (i: Int) -> String {
return String(Array(self)[i])
}
}
Which will now let you use `.length` on strings, e.g:
"Cat".length; //3
And get the character at index with:
"Cat"[1]; //a
I've more useful extensions at: https://github.com/mythz/swift-linq-examples/blob/master/src/LinqExamples/extensions.swift https://github.com/mythz/swift-linq-examples/blob/master/src...
Which enables LINQ-like querying in Swift: https://github.com/mythz/swift-linq-examples https://github.com/mythz/swift-linq-examples