Actions
Bug #10294
closedDir[] cannot be called with an array argument
Description
The documentation for Dir[]
claims that it can be called with an array and it will behave like Dir.glob:
Dir[ array ] → array
Dir[ string [, string ...] ] → array
Equivalent to calling Dir.glob(array,0) and Dir.glob([string,...],0).
However, doing so raises a TypeError:
$ ruby -e "puts Dir[['/bin/bash']]"
-e:1:in `[]': no implicit conversion of Array into String (TypeError)
from -e:1:in `<main>'
Dir.glob works as documented:
$ ruby -e "puts Dir.glob ['/bin/bash']"
/bin/bash
I'm unsure if this is supposed to work as described or if it is a documentation bug, but it is reproducible on 2.0, 2.1, and trunk.
Updated by nobu (Nobuyoshi Nakada) about 10 years ago
- Status changed from Open to Rejected
Not an array of path names, any number of path names,
Dir['/bin/bash', '/bin/sh']
Updated by Anonymous about 10 years ago
I'm aware of what actually works in practice, but the documentation claims both forms are acceptable:
Dir[ array ] → array
Dir[ string [, string ...] ] → array
https://github.com/ruby/ruby/blob/2a8989d71c611884631c4d9ff5dba65aed00cc83/dir.c#L1871-L1877
Updated by nobu (Nobuyoshi Nakada) about 10 years ago
- Category set to doc
- Status changed from Rejected to Open
- Target version set to 2.2.0
- Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED
Updated by nobu (Nobuyoshi Nakada) about 10 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r47850.
dir.c: fix rdoc [ci skip]
- dir.c (dir_s_aref): fix rdoc.
Dir.glob
allows an array but
Dir[]
not. the former accepts an optional parameterflags
,
while the latter accepts arbitrary number of arguments but no
flags
. [ruby-core:65265] [Bug #10294]
Updated by usa (Usaku NAKAMURA) about 10 years ago
- Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: DONE, 2.1: REQUIRED
Backported into ruby_2_0_0
at r47934.
Updated by nagachika (Tomoyuki Chikanaga) about 10 years ago
- Backport changed from 2.0.0: DONE, 2.1: REQUIRED to 2.0.0: DONE, 2.1: DONE
Backported into ruby_2_1
at r47946.
Actions
Like0
Like0Like0Like0Like0Like0Like0