From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 5551A1F462 for ; Mon, 29 Apr 2019 00:05:58 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4AB47120AB2; Mon, 29 Apr 2019 09:05:52 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id B0B74120453 for ; Mon, 29 Apr 2019 09:05:49 +0900 (JST) Received: by filter0144p3mdw1.sendgrid.net with SMTP id filter0144p3mdw1-1965-5CC63FBF-8 2019-04-29 00:05:19.187868796 +0000 UTC m=+272665.282107701 Received: from herokuapp.com (unknown [54.91.45.152]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id i0aU44PsTqyViWXZPX7pRA for ; Mon, 29 Apr 2019 00:05:19.128 +0000 (UTC) Date: Mon, 29 Apr 2019 00:05:19 +0000 (UTC) From: mame@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67953 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15745 X-Redmine-Issue-Author: koic X-Redmine-Sender: mame X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?EJh2gqwnyqXtd++xo=2FinyA1V0bXouTB4FkWnzNiKb4+XfzvmYffhglIeu9q9iO?= =?us-ascii?Q?5gK+ApFD80dFXg34h9hfAF0LEjTjnA0skcYsoy2?= =?us-ascii?Q?AyeB+YPky5FP2gvR8vKKBkKAj8cbEcIHwcDnKwx?= =?us-ascii?Q?FxXfwL+MdCuIrKWjpBSuXSzowqFCItz3JPrzgPC?= =?us-ascii?Q?EOZRdcaP2BRXFQ6F+kLxCuKW4RMByEec+3Q=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92470 Subject: [ruby-core:92470] [Ruby trunk Bug#15745] There is no symmetry in the beginless range and the endless range using `Range#inspect` X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15745 has been updated by mame (Yusuke Endoh). Eregon (Benoit Daloze) wrote: > I'm not sure what you mean by DSL-like usage, but I wouldn't be surprised if many people use it like `array[..-2]` (instead of `array[0..-2]`). > In other words, I'd expect it's approximately as common as endless ranges for the purpose of indexing a sequence. I meant "DSL-like", for example, `debtors = Accounts.where(balance: ...0)`. I strongly prefer `ary[0..]` to `ary[0..-1]` because the former has no magical -1. However, IMHO, there is no strong reason to prefer `ary[..-2]` to `ary[0..-2]` because 0 is not so magical in terms of indexing. It would be useful where non-zero-based indexing is used, but I don't think that it is common in Ruby. In addition, an endless range has another big usage: `(1..).each { ... }`. On the other hand, a beginless range cannot iterate. So, I believe that a beginless range has much less usages, and this is one of the reasons why a beginless range was not introduced with an endless one. That being said, I'm unsure if `Range#inspect` is mainly used for endless range. ---------------------------------------- Bug #15745: There is no symmetry in the beginless range and the endless range using `Range#inspect` https://bugs.ruby-lang.org/issues/15745#change-77818 * Author: koic (Koichi ITO) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.7.0dev (2019-04-03 trunk 67423) [x86_64-darwin17] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- The following commit introduces beginless range. https://github.com/ruby/ruby/commit/95f7992b89efd35de6b28ac095c4d3477019c583 ``` % ruby -v ruby 2.7.0dev (2019-04-03 trunk 67423) [x86_64-darwin17] ``` There is no symmetry with endless range when using `Range#inspect` method. ``` (1..).inspect # => "1.." (..5).inspect # => "nil..5" ``` How about unifying whether it represents `nil`? -- https://bugs.ruby-lang.org/