June 08, 2014 Re: enum scope | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 2014-06-08 19:50, Walter Bright wrote: > Does that apply to all symbols in Swift, or just enums? I'm not sure if it applies to all symbols but it's not limited to enums. The reference documentation [1] says: "An implicit member expression is an abbreviated way to access a member of a type, such as an enumeration case or a class method, in a context where type inference can determine the implied type. It has the following form: .member name For example: var x = MyEnumeration.SomeValue x = .AnotherValue " [1] https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Expressions.html#//apple_ref/swift/grammar/implicit-member-expression -- /Jacob Carlborg |
June 08, 2014 Re: enum scope | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 2014-06-08 19:51, Walter Bright wrote: > That use of with never occurred to me! It's cool. It's very nice. I use it quite heavily in a project where I need to access enum members often. It's mostly useful when you need to access many enum members in the same scope. -- /Jacob Carlborg |
June 08, 2014 Re: enum scope | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On 6/8/2014 12:11 PM, Jacob Carlborg wrote:
> "An implicit member expression is an abbreviated way to access a member of a
> type, such as an enumeration case or a class method, in a context where type
> inference can determine the implied type. It has the following form:
>
> .member name
>
> For example:
>
> var x = MyEnumeration.SomeValue
> x = .AnotherValue
I see, so it is using the type of the lvalue to guide the symbol resolution of the rvalue.
Andrei had proposed something like this a few years ago, but I talked him out of it :-)
(I felt it would play havoc with overload resolution.)
|
June 09, 2014 Re: enum scope | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 08/06/14 21:53, Walter Bright wrote: > I see, so it is using the type of the lvalue to guide the symbol > resolution of the rvalue. > > Andrei had proposed something like this a few years ago, but I talked > him out of it :-) > > (I felt it would play havoc with overload resolution.) I'm pretty sure Swift doesn't support function overloading. They use mandatory named parameters, like Objective-C instead. -- /Jacob Carlborg |
June 09, 2014 Re: enum scope | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 6/9/2014 2:51 AM, Walter Bright wrote:
> On 6/7/2014 4:58 PM, deadalnix wrote:
>> You can even use the with statement for code that use the enum
>> intensively, for instance :
>>
>> final switch(myvar) with(UITableViewRowAnimation) {
>> case Fade:
>> // Do fading...
>> case Right:
>> // That's right...
>> case Left:
>> // That's not right..
>> // And so on...
>> }
>
> That use of with never occurred to me! It's cool.
>
I saw it here in the NG some time ago and have been using it ever since. Love this one.
|
Copyright © 1999-2021 by the D Language Foundation