| Age | Commit message (Collapse) | Author |
|
"Code" (when used to refer to what we create in Ruby or any other programming language) is an abstract non-count noun, so it cannot be pluralized. ("Codes" would be used when referring to specific countable things like PIN codes, which is a different use of the word "code".)
This is somewhat confusing because English allows converting count nouns into non-count nouns, and converting non-count nouns into count nouns, and because many words have both forms.
For an example of converting a non-count noun to a count noun, "water" is normally a non-count noun:
> The world is covered with water.
but people who work in restaurants often use the word as a count noun, as a shorthand for "cup of water":
> I need 7 waters on the big table by the window.
For an example of the opposite conversion, "worm" is normally a count noun:
> There are lots of worms in the puddle.
but someone might use it as a non-count noun when talking about non-distinct remains of worms:
> You have worm all over the bottom of your shoe!
So although a given noun can be flexible enough to be used in either way—even when it is unconventional—there is a definite change of meaning when using a word as a count noun or a non-count noun.
|
|
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?`.
|
|
Based on the example, it appears that `foo.rb` and `main.rb` are expected to be in the same directory.
Since Ruby 1.9, the current directory is not included in `$LOAD_PATH` by default.
As a result, running `box.require('foo')` as shown in the sample code raises a `LoadError`:
```console
main.rb:2:in `Ruby::Box#require': cannot load such file -- foo (LoadError)
from main.rb:2:in `<main>'
```
To avoid this, it seems simplest to show either `box.require('./foo')` or `box.require_relative('foo')`.
In this PR, `box.require('foo')` is replaced with `box.require_relative('foo')` to make the intention of
using a relative path explicit.
This should reduce the chance that users trying Ruby Box will run into an unexpected error.
|
|
|
|
|
|
|
|
|
|
|
|
Re-organize page docs
|