From: Ryan Davis Date: 2010-02-15T09:49:29+09:00 Subject: Re: Compare and delete element from an array On Feb 14, 2010, at 15:45 , Greg Ma wrote: > ... > tags.delete_if { > |x| x.name == tag > puts x.name + "-"+ x.name.length.to_s > puts tag + "-"+ tag.length.to_s > puts "-----" > } > ... > Here we see that the first element should be deleted, but when i display > the array, it has not... delete_if evaluates the block to see if it should delete the element or not. you're debugging with puts (a bad idea to begin with) and puts returns nil. So you're never going to delete anything. I'd also recommend using string interpolation: > puts x.name + "-"+ x.name.length.to_s vs: > puts "#{x.name}-#{x.name.length}"