Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method · added in Ruby 4.1

String#bitwise_not

bitwise_not → string

Returns a new string whose bytes are the bitwise complement of self:

Example
"\x00\xAA".bitwise_not # => "\xFF\x55"

The returned string has BINARY encoding.

Ruby version changes

  1. 4.1