How can I return a Range of Int from a function in Swift? I've searched the Swift 2.1 docs, the web, SO, and tried:
func myfunc() -> Range { // }
func myfunc() -> ( Int ... Int ) { // }
func myfunc() -> Range< Int > { // }
... and many others ...
Sorry for being bone-headed here, and thanks in advance!
Your third one is correct. This compiles and works, for example:
func oneTo10() -> Range<Int> {
return 1...10
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With