Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @packages = ["2", ["4", "2", "1"], "4", ["4","2"], ["5", "6"]]
- @packages = ["2", ["4", "2", "1"], "4", ["4","2"], ["3", "2"]]
- @opposites = ["2", "4"]
- @packages.reject! { |p| p.is_a?(Array) && (@opposites & p).size >= 2 }
- @packages.reject { |a| a.is_a?(Array) && (a & [ '2', '4' ]).length == 2 }
- >> @packages = ["2", ["4", "2", "1"], "4", ["4","2"], ["5", "6"], ["1", "2"], ["4", "11"], ["2", "2", "4"]]
- => ["2", ["4", "2", "1"], "4", ["4", "2"], ["5", "6"], ["1", "2"], ["4", "11"], ["2", "2", "4"]]
- >> @packages.reject { |a| a.is_a?(Array) && (a & [ '2', '4' ]).length == 2 }
- => ["2", "4", ["5", "6"], ["1", "2"], ["4", "11"]]
- rejects = %w(2 4)
- @packages.reject { |a| a.is_a?(Array) && (a & rejects).length == rejects.length }
- @packages.reject{|element| element.is_a?(Array)}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement