Kaldrenon
7/21/2008 4:50:00 PM
On Jul 21, 9:25 am, Li Chen <chen_...@yahoo.com> wrote:
> > [A..Z].each do |letter|
> > [1...num].each do |number|
> > #Process the website in here
> > process_website letter number
> > end
> > end
> In order to break out of the loop what I do is that I compare the website
> address of current page and the previous page. If they are the same I am
> going to break out the current loop and go to next letter. I wonder how
> you implement this idea into the current script.
If I understand what you're asking correctly, it would be something
like this (this is pseudo-code)
[A..Z].each do |letter|
old_website = nil
[1...num].each do |number|
#Process the website in here
new_website = fetch_website(letter, number)
if new_website != old_website
process_website(new_website)
else
#break out of num-loop
end
old_website = new_website
end
end
This is assuming that the only time you will ever have duplication is
when you have reached the end of the loop for a given letter. Is that
correct?