I’m thinking more of default values as an alternative to overloaded enum cases. 
Giving the second parameter a default value equal to whatever the first case 
would have been assuming would obviate the need for overloaded cases here, and 
wouldn’t break the ability to leave out the values by typing “if case 
.javaScript”. All of the usefulness, none of the calories.

Charles

> On Nov 29, 2016, at 9:59 AM, Adrian Zubarev <[email protected]> 
> wrote:
> 
> Hmm, I feel like default values wouldn’t work with overloaded enum cases. 
> 
> In my own project I have something like this:
> 
> case javaScript(String)
> case scopedJavaScript(String, scope: Document)
> 
> // But I'd like it to be:
> case javaScript(String)
> case javaScript(String, scope: Document)
> 
> 
> 
> -- 
> Adrian Zubarev
> Sent with Airmail
> 
> Am 29. November 2016 um 16:55:52, Charles Srstka ([email protected] 
> <mailto:[email protected]>) schrieb:
> 
>>> On Nov 29, 2016, at 9:52 AM, Adrian Zubarev via swift-evolution 
>>> <[email protected] <mailto:[email protected]>> wrote:
>>> 
>>> I just showed a direction of what could be possible. 
>>> 
>>> Personally I think it would be enough if we had this:
>>> 
>>> enum MyEnum {
>>>       
>>>     case a
>>>     case b(Int)
>>>     case b(Int, string: String)
>>> }   
>>> Where .b can be overloaded by it’s associated types.
>>> 
>> 
>> Or default values:
>> 
>> enum MyEnum {
>> case a
>> case b(Int, string: String = “SomeDefault”)
>> }
>> 
>> Charles
>> 
> 
> 

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to