Because it’s a value and has no identity. R+
> On 3 Apr 2017, at 17:58, Zhao Xin <[email protected]> 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 > <[email protected] <mailto:[email protected]>> wrote: >> On 3 Apr 2017, at 16:48, Adrian Zubarev <[email protected] >> <mailto:[email protected]>> 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 > [email protected] <mailto:[email protected]> > https://lists.swift.org/mailman/listinfo/swift-users > <https://lists.swift.org/mailman/listinfo/swift-users> > >
_______________________________________________ swift-users mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-users
