summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorKoichi ITO <koic.ito@gmail.com>2025-12-21 04:47:55 +0900
committerSatoshi Tagomori <tagomoris@gmail.com>2026-01-04 12:53:42 +0900
commitca0fece56a3ddfa6b9ec9cf1652e414929040614 (patch)
tree0c0a22d478c54f92b7f025edd1423a8fb4e95d03 /doc
parentd8d41d7441aabae5e5948f89cd759bbdc3bf5532 (diff)
[DOC] Tweak an example in language/box.md
Although the example code comments indicate that it returns `false`, a non-matching result for `=~` is actually `nil`. ```ruby Foo.foo.blank? #=> false "foo".blank? #=> false ``` https://github.com/ruby/ruby/blob/v4.0.0-preview3/doc/language/box.md?plain=1#L115-L122 This PR replaces `=~` with `match?` so that it returns the expected `false`. Since this makes the result a boolean, it also aligns with the expected behavior of a predicate method name like `blank?`.
Diffstat (limited to 'doc')
-rw-r--r--doc/language/box.md2
1 files changed, 1 insertions, 1 deletions
diff --git a/doc/language/box.md b/doc/language/box.md
index 4bbb70e529..05c0dad985 100644
--- a/doc/language/box.md
+++ b/doc/language/box.md
@@ -100,7 +100,7 @@ The changed definitions are visible only in the box. In other boxes, builtin cla
class String
BLANK_PATTERN = /\A\s*\z/
def blank?
- self =~ BLANK_PATTERN
+ self.match?(BLANK_PATTERN)
end
end