Skip to content

Commit ca0fece

Browse files
koictagomoris
authored andcommitted
[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?`.
1 parent d8d41d7 commit ca0fece

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

doc/language/box.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ The changed definitions are visible only in the box. In other boxes, builtin cla
100100
class String
101101
BLANK_PATTERN = /\A\s*\z/
102102
def blank?
103-
self =~ BLANK_PATTERN
103+
self.match?(BLANK_PATTERN)
104104
end
105105
end
106106

0 commit comments

Comments
 (0)