When I tried to shift bits on my RGB color experiment I've noticed that I couldn't shift a variable number of bits.
The Swift book only states that you move "a number to the left/right"
„The bitwise left shift operator (<<) and bitwise right shift operator (>>) move all bits in a number to the left or the right by a certain number of places, according to the rules defined below.“
Is it intentional only to be able to shift a predefined number of bits?
// Works fine:
let shiftMe: UInt32 = 0xFF0000
let shiftedConst = shiftMe >> 16
// Doesn't work:
let shiftMe: UInt32 = 0xFF0000
let shiftValue:Int = 16
let shiftedConst = shiftMe >> shiftValue
The second example won't compile and throws this error:
Could not find an overload for '>>' that accepts the supplied arguments
Is swift designed like this? Is it a bug and fixed in beta3? (I'm still on beta2 atm.)