Hello,
According to ri, Dir.glob returns false when invoked with a block:
-------------------------------------------------------------- Dir::glob
Dir.glob( string, [flags] ) => array
Dir.glob( string, [flags] ) {| filename | block } => false
···
My observation is that it would be much more useful if the block form
also returned an array, consisting of each filename modified by the
block. I ran into this today and found I had to use the non-block form
with Array#collect.
Is there a good reason for this method being the way it is?
Ian
Ian Macdonald | You must’ve hit the wrong anykey.
System Administrator |
ian@caliban.org |
http://www.caliban.org |
>
running on a directory with 100,000 files - which we do alot. the
construction of array would balloon your process size…
-a
···
On Wed, 10 Mar 2004, Ian Macdonald wrote:
Hello,
According to ri, Dir.glob returns false when invoked with a block:
-------------------------------------------------------------- Dir::glob
Dir.glob( string, [flags] ) => array
Dir.glob( string, [flags] ) {| filename | block } => false
My observation is that it would be much more useful if the block form
also returned an array, consisting of each filename modified by the
block. I ran into this today and found I had to use the non-block form
with Array#collect.
Is there a good reason for this method being the way it is?
–
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: Solar-Terrestrial Physics Data | NCEI
TRY :: for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done
===============================================================================
Good point. It seems, then, that this behaviour should be selectable.
Perhaps there should be a Dir.glob_to_a method, but then again, maybe
that’s overkill, as it’s so easy to chain the non-block version into
Array#collect.
Ian
···
On Thu 11 Mar 2004 at 01:34:38 +0900, Ara.T.Howard wrote:
On Wed, 10 Mar 2004, Ian Macdonald wrote:
According to ri, Dir.glob returns false when invoked with a block:
-------------------------------------------------------------- Dir::glob
Dir.glob( string, [flags] ) => array
Dir.glob( string, [flags] ) {| filename | block } => false
My observation is that it would be much more useful if the block form
also returned an array, consisting of each filename modified by the
block. I ran into this today and found I had to use the non-block form
with Array#collect.
Is there a good reason for this method being the way it is?
running on a directory with 100,000 files - which we do alot. the
construction of array would balloon your process size…
–
Ian Macdonald | Weekends were made for programming. - Karl
System Administrator | Lehenbauer
ian@caliban.org |
http://www.caliban.org |
>