<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Because it’s a value and has no identity.</div><div class=""><br class=""></div><div class="">R+</div><br class=""><div><blockquote type="cite" class=""><div class="">On 3 Apr 2017, at 17:58, Zhao Xin &lt;<a href="mailto:owenzx@gmail.com" class="">owenzx@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif"><div style="font-family:menlo;font-size:13px;margin:0px;line-height:normal" class="">Why not making State as a class? EffectiveState should be subclass of State.</div><div style="font-family:menlo;font-size:13px;margin:0px;line-height:normal" class=""><br class=""></div><div style="font-family:menlo;font-size:13px;margin:0px;line-height:normal" class="">Zhaoxin</div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Apr 3, 2017 at 11:08 PM, Rudolf Adamkovič via swift-users <span dir="ltr" class="">&lt;<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><span class=""><div class=""><blockquote type="cite" class=""><div class="">On 3 Apr 2017, at 16:48, Adrian Zubarev &lt;<a href="mailto:adrian.zubarev@devandartist.com" target="_blank" class="">adrian.zubarev@devandartist.<wbr class="">com</a>&gt; wrote:</div><br class="m_3185120334291325452Apple-interchange-newline"><div class=""><span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(254,254,254);float:none;display:inline!important" class="">Why do you cast against an existential in first place?</span></div></blockquote></div><br class=""></span><div class="">To avoid force-unwrap at the end here:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class=""><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">class</span><span style="font-variant-ligatures:no-common-ligatures" class=""> Store {</span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">var</span><span style="font-variant-ligatures:no-common-ligatures" class=""> state: </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="">State</span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures" class="">// ...</span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class=""> processScheduledActions() {</span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">guard</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">var</span><span style="font-variant-ligatures:no-common-ligatures" class=""> effectfulState = state </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">as</span><span style="font-variant-ligatures:no-common-ligatures" class="">? </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="">Effectful</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">else</span><span style="font-variant-ligatures:no-common-ligatures" class=""> {</span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">return</span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">while</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">let</span><span style="font-variant-ligatures:no-common-ligatures" class=""> actions = effectfulState.<wbr class="">scheduledActions.flush() {</span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">for</span><span style="font-variant-ligatures:no-common-ligatures" class=""> action </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">in</span><span style="font-variant-ligatures:no-common-ligatures" class=""> actions {</span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delegate?.store(</span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">self</span><span style="font-variant-ligatures:no-common-ligatures" class="">, didRequest: action)</span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; state = effectfulState </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="">as</span><span style="font-variant-ligatures:no-common-ligatures" class="">! </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="">State</span></div><div style="margin: 0px; line-height: normal; min-height: 15px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><br class="m_3185120334291325452webkit-block-placeholder"></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div class=""><br class=""></div></div></div><div class="">Thank you!</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class="">R+</span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div></font></span></div><br class="">______________________________<wbr class="">_________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-users</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>