From: Vlad GALU Date: 2006-06-04T07:05:35+09:00 Subject: Re: Where can one find examples of masterful Ruby code? On 6/4/06, Logan Capaldo wrote: > > On Jun 3, 2006, at 4:48 PM, Alder Green wrote: > > > For example: check if integer i is a power of 2, with an expression no > > more than 13 characters long. > > > > Solution: (i & (i - 1)) > > I'm confused. > > > irb(main):001:0> i = 9 > => 9 > irb(main):002:0> (i & (i - 1)) > => 8 > > So 9 is a power of 2? > > As far as 13 characters goes > > (i % 2).zero? > > is _exactly_ 13 characters and it gives a true or false answer > instead of zero of something else. It also tells you if i is a multiple of 2 :) > > > -- If it's there, and you can see it, it's real. If it's not there, and you can see it, it's virtual. If it's there, and you can't see it, it's transparent. If it's not there, and you can't see it, you erased it.