Wow. Very clever. I know pretty much nothing about binary (currently working on changing that), so I guess that explains why I didn't understand it. It's really incredible how much I've learned new skills and refined old skills thanks to this site and its knowledgeable users. Looking forward to learning more, thanks so much for the help!
As alpardel said it's the left bitwise shift operator if applied to a Number
If you take an integer 11 which is 1011 in binary and shift the bits 1 to the left you get 10110 = 22
if you shift them 2 to the left you get 101100 = 44
It's a left-shift bit operator: x << n shifts the bits of 'x' n position to the left, doubling its value once for each shift. E.g.: 3 << 2 = 3 * 2 * 2 = 12
Thanks, that's helpful comment!
Wow. Very clever. I know pretty much nothing about binary (currently working on changing that), so I guess that explains why I didn't understand it. It's really incredible how much I've learned new skills and refined old skills thanks to this site and its knowledgeable users. Looking forward to learning more, thanks so much for the help!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
In Ruby you normally don't say
return something
, you just saysomething
, since the last expression is always the return value of a method invocation.This comment is hidden because it contains spoiler information about the solution
As alpardel said it's the left bitwise shift operator if applied to a Number
If you take an integer 11 which is 1011 in binary and shift the bits 1 to the left you get 10110 = 22
if you shift them 2 to the left you get 101100 = 44
This comment is hidden because it contains spoiler information about the solution
It's a left-shift bit operator: x << n shifts the bits of 'x' n position to the left, doubling its value once for each shift. E.g.: 3 << 2 = 3 * 2 * 2 = 12
http://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts
I thought "<<" only adds things to a hash/array. What is its function here?