From: "Dan0042 (Daniel DeLorme) via ruby-core" Date: 2023-09-20T16:31:38+00:00 Subject: [ruby-core:114845] [Ruby master Feature#13933] Add Range#empty? Issue #13933 has been updated by Dan0042 (Daniel DeLorme). Since 6 years ago, beginless and endless ranges have been added, so `#none?` is no longer sufficient. ```ruby (nil..0).none? #=> TypeError (can't iterate from NilClass) ``` And as mentioned above `Range#size` doesn't work for String ranges. So I think it would be good to have `Range#empty?`, with cover-based semantics rather than succ-based: ```ruby (1..0).empty? #=> true (1..1).empty? #=> false (1...1).empty? #=> true ("a".."b").empty? #=> false ("b".."a").empty? #=> true (nil..0).empty? #=> false (..-Float::INFINITY).empty? #=> false (...-Float::INFINITY).empty? #=> true ``` ---------------------------------------- Feature #13933: Add Range#empty? https://bugs.ruby-lang.org/issues/13933#change-104692 * Author: ted (Ted Johansson) * Status: Open * Priority: Normal ---------------------------------------- Range already responds to #size. It would be nice if it also responded to predicate #empty? :-) -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/