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=-2.8 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=no 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 BBBA81F463 for ; Sat, 4 Jan 2020 17:28:35 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D8B9012096C; Sun, 5 Jan 2020 02:28:18 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 45AE912091B for ; Sun, 5 Jan 2020 02:28:17 +0900 (JST) Received: by filterdrecv-p3mdw1-56c97568b5-zwhxv with SMTP id filterdrecv-p3mdw1-56c97568b5-zwhxv-19-5E10CB36-D 2020-01-04 17:28:22.247718075 +0000 UTC m=+1615515.145410746 Received: from herokuapp.com (unknown [3.84.47.179]) by ismtpd0104p1mdw1.sendgrid.net (SG) with ESMTP id yvtQ54d-Sze6U1Ga3kJ8Yg for ; Sat, 04 Jan 2020 17:28:22.175 +0000 (UTC) Date: Sat, 04 Jan 2020 17:28:22 +0000 (UTC) From: sawadatsuyoshi@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 72316 X-Redmine-Project: ruby-master X-Redmine-Issue-Id: 9587 X-Redmine-Issue-Author: sawa X-Redmine-Sender: sawa 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?jFXA8Rt481sXUUIO9tYW1AJlMOZdNdlSw=2F5TfLCefGsLP3sh97Hkj2sDdA1WIR?= =?us-ascii?Q?wL9Eixo4kvuIEh3AbN7tLwCNw5didDXjT25F0nl?= =?us-ascii?Q?yR6On84Um6qEOwzKDvOnGZTUu673q4gg4wnEOmi?= =?us-ascii?Q?oNLCSneduGCzv0OQMiC88Bt7nMoBobaXYrZIDmq?= =?us-ascii?Q?B8=2FkSo0HBJbKMVTcAhJFmi50OVzrGGcXW6gt0+p?= =?us-ascii?Q?MeL9CEU1f3FT=2Flo5A=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 96654 Subject: [ruby-core:96654] [Ruby master Feature#9587] Integer#times with optional starting value 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 #9587 has been updated by sawa (Tsuyoshi Sawada). I now think that writing as below is good enough: ```ruby 6.times.with_index(1){|_, i| puts "Chapter#{i}"} ``` I withdraw this proposal. Please close it. ---------------------------------------- Feature #9587: Integer#times with optional starting value https://bugs.ruby-lang.org/issues/9587#change-83624 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Just like `Enumerator#with_index` takes an optional argument that specifies the initial value of the index, I would like to request that `Integer#times` take an optional argument that specifies the initial value. The usefulness of it is similar to that of `with_index` taking an argument. We sometimes want to repeat tasks a given number of times, and want to use an index not necessarily starting from `0`. 6.times(1){|i| puts "Chapter #{i}"} should give Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 with the return value `6`. We can do it with `1.upto(6)`, or with `#{i + 1}` within the block, but giving the initial value to `times` is much easier. -- https://bugs.ruby-lang.org/