Ruby delete method (string manipulation)

Posted by brianheys on Stack Overflow See other posts from Stack Overflow or by brianheys
Published on 2010-04-25T07:11:32Z Indexed on 2010/04/25 7:23 UTC
Read the original article Hit count: 348

I'm new to Ruby, and have been working my way through Mr Neighborly's Humble Little Ruby Guide. There have been a few typos in the code examples along the way, but I've always managed to work out what's wrong and subsequently fix it - until now!

This is really basic, but I can't get the following example to work on Mac OS X (Snow Leopard):

gone = "Got gone fool!"
puts "Original: " + gone
gone.delete!("o", "r-v")
puts "deleted: " + gone

Output I'm expecting is:

Original: Got gone fool!
deleted: G gne fl!

Output I actually get is:

Original: Got gone fool!
deleted: Got gone fool!

The delete! method doesn't seem to have had any effect.

Can anyone shed any light on what's going wrong here? :-\

© Stack Overflow or respective owner

Related posts about ruby

Related posts about delete