Hello team,
I have couple questions about the following code.
1. The *break* is taking me out of the two loops. I just want to exit
the inner loop, continuing with the NEXT "e1" value.
2. Since the two lists are sorted, it will be nice to continue within
the inner loop where the last values matched.
3. Each short list (f1) record, contains single words and the size is
1/8 of the long list.
4. Each long list (f2) record has multiple words, anything from 4 to 10.
However, the matching values are ALWAYS the first word.
*# NOTE: the two files are already sorted in ascending order*
f1 = "/ruby/2013/list1short"
f2 = "/ruby/2013/list2long"
f1Array = File.readlines(f1)
f2Array = File.readlines(f2)
f1Array.each do |e1|
# Do something here
f2Array.each do |e2|
# Do something here
if e2.include?(e1) then
puts "e1: #{e1}"
puts "e2: #{e2}"
*break # NOTE: Here I want to exit this inner loop and pick the
next "e1"*
end #if
end # f2
end # f1
Any help will be appreciated.
Thank you
···
--
Ruby Student