← Back to Ruby Operators

Double Right Angle Bracket

The Double Right Angle Bracket (>>) symbol is generally used as a shift operator.

We can use it to shift things like numbers and dates:

> n = 0b11110
=> 30
> "%08b" % (n >> 1)
=> "00001111"

> require 'date'
=> true
> d = Date.new(1995, 12, 25)
=> #<Date: 1995-12-25 ((2450077j,0s,0n),+0s,2299161j)>
> d >> 3
=> #<Date: 1996-03-25 ((2450168j,0s,0n),+0s,2299161j)>

For more on these uses and a couple others (like Proc#>>), check out the Shift Operator page.