From: Peter Hickman Date: 2013-01-30T20:30:54+09:00 Subject: Re: Fail if file isn't present? --047d7b343280c1681504d47fd7b2 Content-Type: text/plain; charset=ISO-8859-1 There is nothing wrong with iterating over an empty list. This will not produce and error, you will need to check the list manually On 30 January 2013 10:31, Wayne Brisette wrote: > I seem to be missing something. If I don't have any .js files in my input > directory, shouldn't this fail and fall into rescue? > > > begin > jsfile = Dir.glob("*.js") # Get the javascript file that > contains the > real hiearachy. > jsfile.each do |f| > js_contents = File.open(f, "rb") {|io| io.read } > process_js(js_contents) > end > rescue > puts "The x7_top.js file must be in the input directory." > exit > end > > - Wayne > > --047d7b343280c1681504d47fd7b2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
There is nothing wrong with iterating over an empty list. = This will not produce and error, you will need to check the list manually


On 30 Jan= uary 2013 10:31, Wayne Brisette <wbrisett@att.net> wrote:
I seem to be missing something. If I don'= ;t have any .js files in my input
directory, shouldn't this fail and fall into rescue?


begin
=A0 jsfile =3D Dir.glob("*.js") =A0 =A0 =A0 =A0 =A0# Get the java= script file that contains the
real hiearachy.
=A0 jsfile.each do |f|
=A0 =A0js_contents =3D File.open(f, "rb") {|io| io.read }
=A0 =A0process_js(js_contents)
=A0 =A0end
rescue
=A0 =A0puts "The x7_top.js file must be in the input directory."<= br> =A0 =A0exit
end

- Wayne


--047d7b343280c1681504d47fd7b2--