From: Greg Ma Date: 2010-02-15T08:45:04+09:00 Subject: Compare and delete element from an array Hi, I try to compare an arroy of Tag and an array of string. I would like to remove from my array of Tag all element that are in the array of string. I,ve done the method below that should be working fine. When i look at the console result, the element are equals, so is should be deleted but it is not. I donc understand why??... :/ #Method in Student Class def remove_tags(array_of_tags) if !array_of_tags.empty? array_of_tags.each do |tag| tags.delete_if { |x| x.name == tag puts x.name + "-"+ x.name.length.to_s puts tag + "-"+ tag.length.to_s puts "-----" } end puts tags end end #result Completed in 95ms (View: 83, DB: 5) | 200 OK [http://localhost/students/1/edit] moi-3 moi-3 ----- greg-4 moi-3 ----- # # Here we see that the first element should be deleted, but when i display the array, it has not... -- Posted via http://www.ruby-forum.com/.