Hi, all.
I've been following the "Sharp knives and glue" thread. It's gotten me
thinking about the things I've already been doing with Ruby. I wanted
to ask for opinions on when it is good, bad, acceptable to extend core
classes like String, Fixnum, Array, Hash.
To be a bit more concrete: Would it be okay to tack on "is?" and "has?"
type methods? Contrived example:
class String
VOGON_VOCABULARY = [
'freddled', 'gruntbuggly', 'micturations', 'plurdled',
'gabbleblotchits', 'lurgid', 'groop', 'foonting',
'turlingdromes', 'hooptiously', 'drangle', 'bindlewurdles',
'gobberwarts', 'blurglecruncheon',
]
VOGON_REGEXP = /#{VOGON_VOCABULARY.join('|')}/i
def vogon?
( VOGON_REGEXP =~ self ).respond_to? '>'
end
end
Pistos
--
Posted via http://www.ruby-forum.com/.