Prev: any ruby libraries for db4o
Next: Cognizance presents INSOMNIA: The Midnight Programming Contest
From: Zathras Draal on 26 Mar 2010 08:44 Hello, i want to write all files from my local directory in an array. Something like (not working): d = Dir.new("/Volumes/System/") d.each {|x| file_list.push(x) } How can i push single filenames through d.each into an array? Thanks a lot in advance! -- Posted via http://www.ruby-forum.com/.
From: Chris Hulan on 26 Mar 2010 09:34 On Mar 26, 8:44 am, Zathras Draal <joon...(a)gmail.com> wrote: > Hello, > > i want to write all files from my local directory in an array. > > Something like (not working): > > d = Dir.new("/Volumes/System/") > d.each {|x| file_list.push(x) } > > How can i push single filenames through d.each into an array? > > Thanks a lot in advance! > -- > Posted viahttp://www.ruby-forum.com/. If file_list did not exist before the block, it will not exist after the block exits. Declarations inside blocks are scoped to the block I think if you look at the docs for Dir you'll find a method that will give you the list of files withtout the need of the block cheers
From: Aldric Giacomoni on 26 Mar 2010 09:44 Chris Hulan wrote: >> On Mar 26, 8:44�am, Zathras Draal <joon...(a)gmail.com> wrote: >> >>Hello, >> >>i want to write all files from my local directory in an array. >> > > > If file_list did not exist before the block, > it will not exist after the block exits. Declarations inside blocks > are scoped to the block > > I think if you look at the docs for Dir you'll find a method that will > give you the list of files withtout the need of the block > cheers Indeed. irb> file_list = Dir.glob('*') -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: any ruby libraries for db4o Next: Cognizance presents INSOMNIA: The Midnight Programming Contest |