[#61424] [REJECT?] xmalloc/xfree: reduce atomic ops w/ thread-locals — Eric Wong <normalperson@...>

I'm unsure about this. I _hate_ the extra branches this adds;

13 messages 2014/03/12

[ruby-core:61263] [ruby-trunk - Feature #9587] Integer#times with optional starting value

From: matthew@...
Date: 2014-03-03 20:10:18 UTC
List: ruby-core #61263
Issue #9587 has been updated by Matthew Kerwin.


 On Mar 3, 2014 10:25 PM, <eregontp@gmail.com> wrote:
 >
 > "10.times(17)" is 170 at me, so it definitely is not an option as an
 unnamed argument.
 
 Strongly agree. Maybe suggest: 10.times(from: 17)

----------------------------------------
Feature #9587: Integer#times with optional starting value
https://bugs.ruby-lang.org/issues/9587#change-45602

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* 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.



-- 
http://bugs.ruby-lang.org/

In This Thread

Prev Next