<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="">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" 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&nbsp;</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><blockquote type="cite" class=""><div class="">On Dec 14, 2015, at 8:20 PM, Gage Morgan via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><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.&nbsp;</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.&nbsp;</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.&nbsp;</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" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="0" 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.&nbsp;</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="acompli_signature">--MGage--</div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=r5jpKsi6nat7oa43lpCLi5GRGm2utDkbDscuFklXZ2eJPJ4boPZNsfTMUXhuzxscfQ2dHfHp3kfeoCOhec2ab-2BO8i1qEISpGs3-2FQEBW7Oj6d5leYACbhcAIF4BH3Zv2BS8SZh7k7rWhEP6osSNkgTd4oIWESIHqQl1oTuvLHAPBqZVGhUk9H9xxpMLiADU9xYh6VjS0UAS2xG4eRwOFgvlwcR2JwZoqilv4sKS32Vao-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></body></html>