Because it’s a value and has no identity.

R+

> On 3 Apr 2017, at 17:58, Zhao Xin <owe...@gmail.com> wrote:
> 
> Why not making State as a class? EffectiveState should be subclass of State.
> 
> Zhaoxin
> 
> On Mon, Apr 3, 2017 at 11:08 PM, Rudolf Adamkovič via swift-users 
> <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
>> On 3 Apr 2017, at 16:48, Adrian Zubarev <adrian.zuba...@devandartist.com 
>> <mailto:adrian.zuba...@devandartist.com>> wrote:
>> 
>> Why do you cast against an existential in first place?
> 
> To avoid force-unwrap at the end here:
> 
> class Store {
> 
>     var state: State
> 
>     // ...
> 
>     func processScheduledActions() {
> 
>         guard var effectfulState = state as? Effectful else {
>             return
>         }
> 
>         while let actions = effectfulState.scheduledActions.flush() {
>             for action in actions {
>                 delegate?.store(self, didRequest: action)
>             }
>         }
> 
>         state = effectfulState as! State
>         
>     }
> 
> }
> 
> Thank you!
> 
> R+
> 
> 
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org <mailto:swift-users@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users 
> <https://lists.swift.org/mailman/listinfo/swift-users>
> 
> 

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to