-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add #empty? to Tempfile, StringIO, File::Stat #1759
base: master
Are you sure you want to change the base?
Conversation
fc1f398
to
c717414
Compare
I couldn't find where to add tests for |
ext/stringio/stringio.c
Outdated
rb_raise(rb_eIOError, "not opened"); | ||
} | ||
long len = RSTRING_LEN(string); | ||
if (len == 0) { return Qtrue; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since len
is not used anywhere else but that if
, can this be equivalent?
if (RSTRING_LEN(string) == 0) { return Qtrue; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
c717414
to
7a939cc
Compare
Would love to see this merged in the name of 🦆 typing. 🙂 |
Same here. |
Rubocop prefers `empty?` over `length == 0` and `size == 0`, which is great for String, Array, Hash, etc. It would be nice if more classes implemented `#empty?` for consistancy. See related discussion at rubocop/rubocop#2841
4ff82b3
to
28fbcde
Compare
Rubocop prefers
empty?
overlength == 0
andsize == 0
, which is great for String, Array, Hash, etc. It would be nice if more classes implemented#empty?
for consistency.See related discussion at rubocop/rubocop#2841
https://bugs.ruby-lang.org/issues/14136