Programming-Idioms

History of Idiom 42 > diff from v25 to v26

Edit summary for version 26 :
New Ruby implementation by user [steenslag]

Version 25

2016-02-18, 16:57:59

Version 26

2016-04-06, 19:30:20

Idiom #42 Continue outer loop

Print each item v of list a which in not contained in list b.
For this, write an outer loop to iterate on a and an inner loop to iterate on b.

Idiom #42 Continue outer loop

Print each item v of list a which in not contained in list b.
For this, write an outer loop to iterate on a and an inner loop to iterate on b.

Code
a.each do |v|
  catch :matched do
    b.each do |u|
      throw :matched if v == u
    end
    puts v
  end  
end
Comments bubble
Idiomatic ruby would be: puts a-b