[swift-evolution] ternary operator ?: suggestion

Marcelo Alves marcelo.alves at me.com
Tue Jan 5 12:37:57 CST 2016


> On Jan 5, 2016, at 16:06, Thorsten Seitz via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> Am 05.01.2016 um 18:12 schrieb Matthew Johnson <matthew at anandabits.com <mailto:matthew at anandabits.com>>:
>> 
>>>>>> On Jan 5, 2016, at 12:29 AM, Thorsten Seitz via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>>>> 
>>>>>> I once suggested the following ternary like switch:
>>>>>> 
>>>>>> let x = color ?
>>>>>>      case .Red: 0xFF0000
>>>>>>      case .Green: 0x00FF00
>>>>>>      case .Blue: 0x0000FF 
>>>>>>      default: 0xFFFFFF
>>>>> 
>>>>> 
>> 
>> Is anybody going to write up a proposal for the ternary-like switch expression?
>> 
> 
> I’ll give it a try.

Any reason to not use switch let x = color … ? We already have if let, guard let, so I think switch let is pretty “swift-ly”.

:: marcelo.alves
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160105/6d3b4503/attachment.html>


More information about the swift-evolution mailing list