[DOC] Fix typo in example code for String#encode method

The example code in the documentation for the `String#encode` method has
a typo in the `fallback` option. The example code uses `h` as the
fallback option, but it should use `hash` instead to match the variable
name in the example code.
This commit is contained in:
Alexander Ross 2024-05-14 10:22:36 +02:00 committed by GitHub
parent 44f50f4179
commit 41e6fd066e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -419,7 +419,7 @@ These keyword-value pairs specify encoding options:
hash = {"\u3042" => 'xyzzy'}
hash.default = 'XYZZY'
s.encode('ASCII', fallback: h) # => "xyzzyfooXYZZY"
s.encode('ASCII', fallback: hash) # => "xyzzyfooXYZZY"
def (fallback = "U+%.4X").escape(x)
self % x.unpack("U")