Returns the result of shifting a value’s binary representation the specified number of digits to the left, masking the shift amount to the type’s bit width, and stores the result in the left-hand-side variable.
Required. Default implementation provided.
- Xcode 9.0+
- Swift Standard Library
The value to shift.
The number of bits to shift
lhsto the left. If
rhsis outside the range
0..<lhs, it is masked to produce a value within that range.
&<<= operator performs a masking shift, where the value used as
rhs is masked to produce a value in the range
0..<lhs. The shift is performed using this masked value.
The following example defines
x as an instance of
UInt8, an 8-bit, unsigned integer type. If you use
2 as the right-hand-side value in an operation on
x, the shift amount requires no masking.
However, if you pass
rhs, the method first bitmasks
3, and then uses that masked value as the number of bits to shift