[#66126] Creation/Conversion methods/functions table for Ruby types — SASADA Koichi <ko1@...>
Hi,
5 messages
2014/11/07
[#66248] [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations — normalperson@...
Issue #10423 has been updated by Eric Wong.
3 messages
2014/11/13
[#66595] [ruby-trunk - Bug #10557] [Open] Block not given when the argument is a string — bartosz@...
Issue #10557 has been reported by Bartosz Kopinski.
3 messages
2014/11/30
[ruby-core:66076] [ruby-trunk - Bug #10475] [Open] Array#flatten should not accept a nil argument
From:
dov.murik@...
Date:
2014-11-04 14:37:23 UTC
List:
ruby-core #66076
Issue #10475 has been reported by Dov Murik. ---------------------------------------- Bug #10475: Array#flatten should not accept a nil argument https://bugs.ruby-lang.org/issues/10475 * Author: Dov Murik * Status: Open * Priority: Normal * Assignee: * Category: core * Target version: * ruby -v: ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- Currently `Array#flatten` accepts an explicit `nil` argument which has the same meaning as `-1` (or no arguemnt) - meaning endless recursive flattening. I'd expect `flatten` to accept an integer argument only (or not at all, with a default of `-1`). Moreover, the behaviour of `arr.flatten(-1)` is not described in the method's documentation. **Current behaviour** (Ruby 2.1.4): ~~~ 2.1.4 :001 > arr = [1, [2, [3, [4, 5]]]] => [1, [2, [3, [4, 5]]]] 2.1.4 :002 > arr.flatten => [1, 2, 3, 4, 5] 2.1.4 :003 > arr.flatten(-1) => [1, 2, 3, 4, 5] 2.1.4 :004 > arr.flatten(nil) => [1, 2, 3, 4, 5] ~~~ **Expected behaviour**: * The last call (`arr.flatten(nil)`) should raise ArgumentError exception. * The -1 (as "indefinite") should be documented. Note that this suggestion will break applications/gems that rely on the fact that `arr.flatten(nil)` is identical to `arr.flatten`. I'd like to hear your opinions on this. If accepted, I'm willing to try and write a patch. -- https://bugs.ruby-lang.org/