Skip to content

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

instance method

String#bitwise_not!

bitwise_not! → self

Replaces each byte in self with its bitwise complement; returns self:

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

The encoding of self is not changed.