Re: More elegance than a long if/else

2017-03-11 Thread Quincey Morris
On Mar 11, 2017, at 06:30 , Pascal Bourguignon wrote: > > My argument is that algebraic expressions are clearer than switches. And it’s a *convincing* argument when you switch to a purely arithmetic problem (such as: how to add two numbers). Seriously, though, I

Re: More elegance than a long if/else

2017-03-11 Thread Pascal Bourguignon
> On 11 Mar 2017, at 09:57, Quincey Morris > wrote: > > On Mar 10, 2017, at 17:35 , Pascal Bourguignon > wrote: >> >> this is much clearer in intent than return x+y. So much clearer… > > My

Re: More elegance than a long if/else

2017-03-11 Thread Quincey Morris
On Mar 10, 2017, at 17:35 , Pascal Bourguignon wrote: > > this is much clearer in intent than return x+y. So much clearer… My argument is not that the original solution was clearer because longer, but that it was longer because clearer.

Re: More elegance than a long if/else

2017-03-10 Thread Pascal Bourguignon
> On 10 Mar 2017, at 23:32, Quincey Morris > wrote: > > On Mar 10, 2017, at 08:24 , Bryan Vines wrote: >> >> Would integer division work better than the modulus operator? > > It would certainly work better in the sense that division is

Re: More elegance than a long if/else

2017-03-10 Thread Quincey Morris
On Mar 10, 2017, at 08:24 , Bryan Vines wrote: > > Would integer division work better than the modulus operator? It would certainly work better in the sense that division is the right operator and modulus is the wrong one! Regarding the original question, I would add that

Re: More elegance than a long if/else

2017-03-10 Thread Bryan Vines
Would integer division work better than the modulus operator? batteryIcon.image = UIImage(named:"\(min(10, (Int(_myBatteryLevel) / 10) + 1))") -- Bryan Vines > On Mar 10, 2017, at 9:54 AM, Jeff Kelley wrote: > > I realized after sending that 100 won’t be correct, so

Re: More elegance than a long if/else

2017-03-10 Thread Jeff Kelley
I realized after sending that 100 won’t be correct, so you’ll need something like this: batteryIcon.image = UIImage(named: "\(min(10, (_myBatteryLevel % 10) + 1))") Jeff Kelley slauncha...@gmail.com | @SlaunchaMan | jeffkelley.org On Fri, Mar 10, 2017 at

Re: More elegance than a long if/else

2017-03-10 Thread Eric E. Dolecki
Thank you! On Fri, Mar 10, 2017 at 10:48 AM Jeff Kelley wrote: > Something like this should work: > > batteryIcon.image = UIImage(named: "\((_myBatteryLevel % 10) + 1)") > > > Jeff Kelley > > slauncha...@gmail.com | @SlaunchaMan | >

Re: More elegance than a long if/else

2017-03-10 Thread Jeff Kelley
Something like this should work: batteryIcon.image = UIImage(named: "\((_myBatteryLevel % 10) + 1)") Jeff Kelley slauncha...@gmail.com | @SlaunchaMan | jeffkelley.org On Fri, Mar 10, 2017 at 10:41 AM, Eric E. Dolecki wrote: > I have this

More elegance than a long if/else

2017-03-10 Thread Eric E. Dolecki
I have this super simple code, but I'd like to whittle it down to something a lot smaller - basically looking for multiples of 10 (100-0) for a value. I need coffee, what's a great way to do this in Swift 3? if _myBatteryLevel >= 90 { batteryIcon.image = UIImage(named: "10") }