def cleanup(x) s = x.read return s.gsub(/BAD_CHARS/, '') end s = "my string with bad cars" cleanup(s) # Exception, no method error 'read' for class String # ok, let's ducktype s class String def read return self end end cleanup(s) # whoot works. # if it walks like a duck and talks like a duck, then it must be....