<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="">Not Nicholas, but I thought I’d share one of my use cases.<div class=""><br class=""></div><div class="">I use a enum (with a Int raw value) for sections in a table view, so whenever the table view asks for the number of rows I pass in the number of cases. Currently, I’m doing something like this:</div><div class=""><br class=""></div><div class="">enum Sections: Int {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>case section1: 0</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>case section2</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>case section3</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>case _count</div><div class="">}</div><div class=""><br class=""></div><div class="">Obviously, this cases issues in switch statements since I need to handle the _count case with an assertion, but other than that it works rather well.</div><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: 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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Saagar Jha</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On May 10, 2017, at 01:04, Yuya Hirayama via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div id="bloop_customfont" 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; -webkit-text-stroke-width: 0px; margin: 0px;" class="">Hi, Nick.</div><div id="bloop_customfont" 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; -webkit-text-stroke-width: 0px; margin: 0px;" class="">I have no idea about it and am interested in why you want to count the cases.</div><br 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; -webkit-text-stroke-width: 0px;" class=""><div id="bloop_sign_1494403280796988928" class="bloop_sign" 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; -webkit-text-stroke-width: 0px;"><div style="font-family: helvetica, arial; font-size: 13px;" class="">-- <br class="">Yuya Hirayama<br class=""></div></div><br 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; -webkit-text-stroke-width: 0px;" class=""><p class="airmail_on" 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; -webkit-text-stroke-width: 0px;">On 2017年5月10日 at 16:58:41, Nicholas Maccharoli via swift-evolution (<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>) wrote:</p><blockquote type="cite" class="clean_bq" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><span class=""><div class=""><div class=""></div><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family: 'comic sans ms', sans-serif; color: rgb(39, 78, 19);">Swift-Evolution, </div><div class="gmail_default" style="font-family: 'comic sans ms', sans-serif; color: rgb(39, 78, 19);"><br class=""></div><div class="gmail_default" style="font-family: 'comic sans ms', sans-serif; color: rgb(39, 78, 19);">I'm sorry if this has been brought up before but is there a reason why there is no built-in way of getting the number of cases an enum defines?</div><div class="gmail_default" style="font-family: 'comic sans ms', sans-serif; color: rgb(39, 78, 19);"><br class=""></div><div class="gmail_default"><span style="color: rgb(39, 78, 19); font-family: 'comic sans ms', sans-serif;" class="">Given something like: enum MyEnum { case foo, bar, baz }</span></div><div class="gmail_default"><span style="color: rgb(39, 78, 19); font-family: 'comic sans ms', sans-serif;" class=""><br class=""></span></div><div class="gmail_default"><font color="#274E13" face="comic sans ms, sans-serif" class="">It would be nice to get the number of cases this enum defines, something like:</font></div><div class="gmail_default"><font color="#274E13" face="comic sans ms, sans-serif" class=""><br class=""></font></div><div class="gmail_default"><font color="#274E13" face="comic sans ms, sans-serif" class=""> MyEnum.count</font></div><div class="gmail_default"><font color="#274E13" face="comic sans ms, sans-serif" class=""><br class=""></font></div><div class="gmail_default"><font color="#274E13" face="comic sans ms, sans-serif" class="">Looking forward to hearing back about this!</font></div><div class="gmail_default"><font color="#274E13" face="comic sans ms, sans-serif" class=""><br class=""></font></div><div class="gmail_default"><font color="#274E13" face="comic sans ms, sans-serif" class="">- Nick </font></div><div class="gmail_default"><font color="#274E13" face="comic sans ms, sans-serif" class=""><br class=""></font></div><div class="gmail_default"><font color="#274E13" face="comic sans ms, sans-serif" class=""><br class=""></font></div><div class="gmail_default" style="font-family: 'comic sans ms', sans-serif; color: rgb(39, 78, 19);"><br class=""></div></div>_______________________________________________<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></span></blockquote><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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br 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; -webkit-text-stroke-width: 0px;" 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br 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; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br 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; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></body></html>