Re: [swift-evolution] [proposal] Treat (case .Foo = bar) as a Boolean expression

2016-05-11 Thread Vladimir.S via swift-evolution
Btw, do we have now any proposal now for enums improvement in Swift3 ? On 11.05.2016 6:31, Chris Lattner via swift-evolution wrote: On May 10, 2016, at 4:33 AM, Sam Dods via swift-evolution mailto:swift-evolution@swift.org>> wrote: I propose that *(case .Foo = bar)* should be treated as an ex

Re: [swift-evolution] [proposal] Treat (case .Foo = bar) as a Boolean expression

2016-05-11 Thread Thorsten Seitz via swift-evolution
Am 11. Mai 2016 um 05:31 schrieb Chris Lattner via swift-evolution : On May 10, 2016, at 4:33 AM, Sam Dods via swift-evolution wrote: I propose that (case .Foo = bar) should be treated as an expression with a Boolean value, so the result can be set to a variable or returned from a method

Re: [swift-evolution] [proposal] Treat (case .Foo = bar) as a Boolean expression

2016-05-10 Thread Chris Lattner via swift-evolution
> On May 10, 2016, at 8:46 PM, Eduardo Mourey Lopez Ne > wrote: > > Hi Chris > > I do agree that it is incosistent that case works in an if but you can’t > assign it to a bool. Not to me. I can understand why you would think about it that way, but the let in “if let” is not assignable to a

Re: [swift-evolution] [proposal] Treat (case .Foo = bar) as a Boolean expression

2016-05-10 Thread Eduardo Mourey Lopez Ne via swift-evolution
Hi Chris I do agree that it is incosistent that case works in an if but you can’t assign it to a bool enum Bar { case foo(name: String) case notFoo case unknownFoo } var xx = Bar.foo(name: "Hello") if case Bar.foo(let name) = xx where name == "Hello” { //This work ok print("H

Re: [swift-evolution] [proposal] Treat (case .Foo = bar) as a Boolean expression

2016-05-10 Thread Chris Lattner via swift-evolution
> On May 10, 2016, at 4:33 AM, Sam Dods via swift-evolution > wrote: > > I propose that (case .Foo = bar) should be treated as an expression with a > Boolean value, so the result can be set to a variable or returned from a > method. I agree that this is an important use case that Swift doesn

Re: [swift-evolution] [proposal] Treat (case .Foo = bar) as a Boolean expression

2016-05-10 Thread Vladimir.S via swift-evolution
Personally I feel like this construction "case .foo = bar" is alien in Swift.. Is it assignment ? No. Is it equality sign? No, we use '==' when checking for the equality. Is it clear what does this construction mean? I'd like to see at least something like `bar is case .foo` or `bar in case .foo

Re: [swift-evolution] [proposal] Treat (case .Foo = bar) as a Boolean expression

2016-05-10 Thread Patrick Smith via swift-evolution
I like the idea of a boolean expression! I think it is cleaner; the required if statement is a pain. For the second idea, I’ve wondered if there could be some way of unwrapping the associated values: case .foo(?) = bar It would produce an optional. This would let you do: let isAlan = (case .f

[swift-evolution] [proposal] Treat (case .Foo = bar) as a Boolean expression

2016-05-10 Thread Sam Dods via swift-evolution
I propose that (case .Foo = bar) should be treated as an expression with a Boolean value, so the result can be set to a variable or returned from a method. Considering the following enumeration: enum Bar { case foo(name: String) case notFoo case unknownFoo } Instead of having to do the fo