Re: [swift-users] overloading methods where only difference is optional vs. non-optional type

2017-10-10 Thread Howard Lovatt via swift-users
func funny() -> Int { return 1 } func funny() -> String { return "2" } let i: Int = funny() let s: String = funny() Is fine. Since Swift knows the return type required. However, it can’t infer the type of: let q = funny() -- Howard. > On 11 Oct 2017, at 4:36 am, C. Keith Ray via swift-us

Re: [swift-users] overloading methods where only difference is optional vs. non-optional type

2017-10-10 Thread C. Keith Ray via swift-users
You need to know that the NAME of a method or function isn't just outside the parenthesis. The name of func IsTextEmpty(foo : String?) -> Bool? is "IsTextEmpty(foo:)" and the name of func IsTextEmpty(text : String?) -> Bool is "IsTextEmpty(text:)" The argument labels ar

Re: [swift-users] overloading methods where only difference is optional vs. non-optional type

2017-10-10 Thread C. Keith Ray via swift-users
nope. it's the same as this example: func funny() -> Int { return 1 } func funny() -> String { return "2" } print(funny()) // the compiler doesn't know which one you want. // the above doesn't compile. // error: forloop.playground:8:1: error: ambiguous use of 'funny()' You have to have some

[swift-users] overloading methods where only difference is optional vs. non-optional type

2017-10-10 Thread Phil Kirby via swift-users
2 down vote favorite Original StackOverflow post: https://stackoverflow.com/questions/46620311/overloading-methods-where-only-difference-is-optional-vs-non-optional-type I was under the impression that swift can have overloaded methods that differ only in the type of object that the methods return

Re: [swift-users] Why does the withUnsafeMutableBufferPointer closure take an inout parameter?

2017-10-10 Thread Martin R via swift-users
Thank you Howard for you response! However, I have a follow-up question: Why are UnsafeMutableBufferPointer methods which modify not the buffer pointer itself, but only the pointed-to memory, mutating at all? UnsafeMutable(Buffer)Pointer already have non-mutating subscript setters, which means