<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="">-1 on Bool extension, this should exist as a free function. Reason?<div class=""><br class=""></div><div class="">(1 + 1 == 2).ifTrue("foo", otherwise: "bar")</div><div class=""><br class=""></div><div class="">This: 1. doesn't look well; 2. is not clear and understandable; 3. doesn't allow condition to be a closure.</div><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><font color="#929292" class=""><br class="Apple-interchange-newline">Pozdrawiam – Regards,</font></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><font color="#929292" class="">Adrian Kashivskyy</font></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Wiadomość napisana przez Sean Heber &lt;<a href="mailto:sean@fifthace.com" class="">sean@fifthace.com</a>&gt; w dniu 04.12.2015, o godz. 16:54:</div><br class="Apple-interchange-newline"><div class=""><div class="">Could alternatively could take a page from Smalltalk:<br class=""><br class=""> &nbsp;&nbsp;extension Bool {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;func ifTrue&lt;T&gt;(@autoclosure isTrue: () -&gt; T, @autoclosure otherwise isFalse: () -&gt; T) -&gt; T {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if self {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return isTrue()<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return isFalse()<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br class=""> &nbsp;&nbsp;}<br class=""><br class="">:)<br class=""><br class="">l8r<br class="">Sean<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Dec 4, 2015, at 1:40 AM, David Waite &lt;<a href="mailto:david@alkaline-solutions.com" class="">david@alkaline-solutions.com</a>&gt; wrote:<br class=""><br class="">Of course one could just drop it as a grammatical language feature and turn it a standard library feature of some form, e.g.:<br class=""><br class="">@warn_unused_result<br class="">func when&lt;T&gt;(@autoclosure expr: ()-&gt;Bool, @autoclosure value: ()-&gt;T, @autoclosure otherwise: ()-&gt;T) -&gt; T {<br class=""> &nbsp;if expr() {<br class=""> &nbsp;&nbsp;&nbsp;return value()<br class=""> &nbsp;}<br class=""> &nbsp;else {<br class=""> &nbsp;&nbsp;&nbsp;return otherwise()<br class=""> &nbsp;}<br class="">}<br class=""><br class="">var a = when(1 + 1 == 2, value: "works", otherwise: "fails")<br class=""><br class="">print(a) // =&gt; “works"<br class=""><br class="">-DW<br class=""><br class=""><blockquote type="cite" class="">On Dec 4, 2015, at 12:26 AM, David Hart &lt;<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>&gt; wrote:<br class=""><br class="">I also tend to agree but I don't like the ordering in the Python version and would rather see the introduction of the then keyword<br class=""><br class="">On 04 Dec 2015, at 06:08, Sean Heber &lt;<a href="mailto:sean@fifthace.com" class="">sean@fifthace.com</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">I agree that using ? for ternary feels.. uncomfortable in Swift. I wouldn't mind seeing Python-style or just eliminating it entirely in favor of simplicity.<br class=""><br class="">l8r<br class="">Sean<br class=""><br class="">On Dec 3, 2015, at 10:48 PM, Dan Appel &lt;<a href="mailto:dan.appel00@gmail.com" class="">dan.appel00@gmail.com</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">I agree that ternary can make code unreadable, especially so with the ‘?’. I personally like the Haskel option the most, but it introduces a new keyword ‘then’, which isn’t great either. Python’s "y if x else z" is therefore, in my opinion, the best alternative.<br class=""><br class="">Also, I found it interesting how split the Rust community was about removing the ternary operator.<br class=""><br class="">— <br class="">Dan Appel<br class=""><br class="">On Thu, Dec 3, 2015 at 7:58 PM J. Cheyo Jimenez &lt;<a href="mailto:cheyo@masters3d.com" class="">cheyo@masters3d.com</a>&gt; wrote:<br class="">Would you consider replacing the C style ?: ternary operator to something that does not use the question mark and colon ? <br class=""><br class="">The use of "?" can be confusing when speed reading code with optionals. <br class=""><br class="">Consider this code as somebody learning swift as their first language.<br class="">let result = !condition ? 1 : 2<br class=""><br class=""><br class="">Some alternatives:<br class=""><br class="">Haskel <br class="">if predicate then expr1 else expr2<br class="">Python<br class="">result = x if a &gt; b else y<br class="">The advantage of not using the question mark is that the language will be more consistency on the use of "?" to mean only optionals. <br class=""><br class=""><br class="">References:<br class=""><a href="https://devforums.apple.com/message/1020139#1020139" class="">https://devforums.apple.com/message/1020139#1020139</a><br class="">https://github.com/rust-lang/rust/issues/1698#issuecomment-3705066<br class=""> _______________________________________________<br class="">swift-evolution mailing list<br class="">swift-evolution@swift.org<br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class="">swift-evolution@swift.org<br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote> _______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></div></blockquote></div><br class=""></div></body></html>