> On May 10, 2016, at 7:11 PM, Eduardo Mourey Lopez Ne via swift-evolution
> <[email protected]> wrote:
>
> current:
> func myComplexOperation() -> Int {
> //Some long complex code that might return some value
> //Default return at the very end
> return 0
> }
>
> proposal:
> func myComplexOperation() -> Int {
> //set the default return at the begging using the ‘default’ keyword or
> some other keyword
> default 0
> //Some long complex code that might return a value
> //if the end of the function is reached, return the default
> }
>
> The other alternative will be to allow naming the return value
> proposal2:
> func myComplexOperation() -> result:Int {
> //set the default return at the begging using the output variable name
> result = 0
> //Some long complex code that might return some value
> }
>
> Another alternative will be to set the default value directly like and
> optional parameter
> proposal3:
> func myComplexOperation() -> Int = 0 {
> //Some long complex code that might return some value
> }
Is this really that much more convenient than:
func myComplexOperation() -> Int {
let default = 0
// do something
return default
}
to justify a whole language feature?
Charles
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution