27 Nov '15, 11pm

Trying to figure out the "&" operator. (NOT &&). What does it do in this program? https://t.co/sSFZLIIFzF

Hi there. I'm very new to Ruby and I'm trying to figure out what the "&" operator does in this program. From this link I understand that it can have different meanings and uses, depending on context. The program I'm studying is very simple and should just tell me if the provided number is a power of 2, or not. I had a very long C++ style solution for it, but then found another, more elegant solution online: def ispow2(n) n & (n – 1) == 0 end So... here is my first encounter with a single ampersand and it's confusing a lot. Can someone please clarify how this program is able to tell me if "n" is a power of 2? Thanks in advance. - Aspiring Rubyist

Full article: https://www.reddit.com/r/ruby/comments/3uiqqn/trying_to_f...

Tweets

Just in case you are trying to figure out what ...

clivecoffee.com 05 Dec '15, 6pm

We have long admired the build quality and brewing performance of Quick Mill machines. They are unrivaled in the craft of ...

Whoa, comparing himself to paul, dude, just go ...

mothership.sg 28 Nov '15, 7am

“Was Paul defiant in his attitude toward the Roman rulers? Was he afraid to be punished for breaking the law? Paul had tau...