<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">In fact, there's no really good reason to use any construct, whether struct, class, or enum, for this at all since the BMI isn't a "thing" per se. A global function might be a better fit.</div><div class=""><br class=""></div><div class=""><a href="http://swiftstub.com/443052056" class="">http://swiftstub.com/443052056</a></div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Dec 15, 2015, at 7:10 AM, Eimantas Vaiciunas via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: 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-stroke-width: 0px;" class="">I exchanged a class to an enum since the BMI values are a finite set. This eliminates a need for valid value check since the switch that is used to initialise the enum value is exhaustive.<div class=""><br class=""></div><div class=""><a href="http://swiftstub.com/242291010/" class="">http://swiftstub.com/242291010/</a><br class=""></div></div><div class="gmail_extra" style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: 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-stroke-width: 0px;"><br class=""><div class="gmail_quote">On Tue, Dec 15, 2015 at 3:30 PM, Erica Sadun via swift-users<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class="">Leaving aside typos, any discussion about the merits of BMI, and the intemperate language in the code, you do a few things that could be improved upon language-wise. Of these, the most egregious is the final "break the machine" else statement that can never be reached.</div><div class=""><br class=""></div><div class="">The following example does several things:</div><div class=""><a href="http://swiftstub.com/358512527" target="_blank" class="">http://swiftstub.com/358512527</a></div><div class=""><br class=""></div><div class="">* Adds a precondition to ensure that clients have passed valid arguments</div><div class="">* Uses an enumeration (with a default value) instead of overloading a class function with nearly identical code</div><div class="">* Introduces a multiplier to address the kg/lb difference</div><div class="">* Establishes an upper case name for the class</div><div class="">* Uses a switch statement instead of cascaded ifs </div><div class="">* Returns a String instead of running procedurally</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">On Dec 14, 2015, at 8:20 PM, Gage Morgan via swift-users <<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>> wrote:</div><br class=""></div></div><div class=""><div class=""><div class="h5"><div class="">For most languages I try out, my own version of "Hello World!" is a BMI calculator. Swift has passed, I encourage you to try it out. </div><div class=""><br class=""></div><div class="">There are two methods called towards the end of file:</div><div class="">1) bmi.pounds(weight, height) - Replace numbers inside with your own if you want to test out in US Customary units. </div><div class=""><br class=""></div><div class="">2) bmi.kilograms(weight, height) - Replace numbers inside with your own if you want to test out in Metric units used everywhere outside the US. </div><div class=""><br class=""></div><div class="">You already get the gist, the bits can be found here:</div><div class=""><a dir="ltr" href="https://gist.github.com/anonymous/9284017644567c29c7f8" target="_blank" class="">https://gist.github.com/anonymous/9284017644567c29c7f8</a></div><div class=""><br class=""></div><div class="">If there's a bug please let me know, but it works in IBM's Sandbox. </div><div class="">(Yes, ALL code was written by me without help. Very close to C, just a bit laid back.)<br class=""><div class="">--MGage--</div><br class=""></div></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=r5jpKsi6nat7oa43lpCLi5GRGm2utDkbDscuFklXZ2eJPJ4boPZNsfTMUXhuzxscfQ2dHfHp3kfeoCOhec2ab-2BO8i1qEISpGs3-2FQEBW7Oj6d5leYACbhcAIF4BH3Zv2BS8SZh7k7rWhEP6osSNkgTd4oIWESIHqQl1oTuvLHAPBqZVGhUk9H9xxpMLiADU9xYh6VjS0UAS2xG4eRwOFgvlwcR2JwZoqilv4sKS32Vao-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span class="Apple-converted-space"> </span>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=lQckFwdSYCkaJC-2BMD1TyWdosrllnnNMdVzdfbO82jL6iCbkn9yUcIkVTsUM2NtwF-2FKUhRmGXKcqVa3GqIqyECXR1EZEHXx7yyXOwyHIb8KOWZSm1vcJe2w5nVp0eADmuP8dbwGUtkk1auEQ0sJ2gLxQvdcQAwvkWUmOLl-2FGHYBt0Mm-2BXLIEOtkCQY6DsBYXwpv4VltZGcr65mmFNw9ZPP5ajs1AcqQ11tpAaDS33we4-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""></div><br 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/mailman/listinfo/swift-users</a><br class=""><br class=""></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=r5jpKsi6nat7oa43lpCLi5GRGm2utDkbDscuFklXZ2eMLxTlaUs-2FZVX0Eifxi0nP6muvA7m0pP30R-2FZ6uX9L-2Fm5YO-2FLXzr5U8kUVPjZxUnWKsq6toKgP4IQtl6z7vS3enaXrh7Li3x2ECeUYlclg6ks4Csp0NSdNLio7w-2BzjqxMKy7NoVDs68sLM5IEpqP7uJbzbYpXIc5DO1GakY3GpXHr9D4LhzC4am-2BjBMP9CMkk-3D" alt="" width="1" height="1" border="0" style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: 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-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: 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-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span>_______________________________________________</span><br style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: 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-stroke-width: 0px;" class=""><span style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: 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-stroke-width: 0px; float: none; display: inline !important;" class="">swift-users mailing list</span><br style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: 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-stroke-width: 0px;" class=""><a href="mailto:swift-users@swift.org" style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: 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-stroke-width: 0px;" class="">swift-users@swift.org</a><br style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: 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-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" style="font-family: Palatino-Roman; font-size: 14px; font-style: normal; font-variant: 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-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-users</a></div></blockquote></div><br class=""></body></html>