Irritating Class methods modification
-
I have found two instances of modification of Class' build-in methods!
It is extremely irritating and very hard to trace.It is an example from TS exporter by Paul Gausden!
# add == to color class Sketchup;;Color def ==(c) return (c.alpha==self.alpha and c.red==self.red and c.green==self.green and c.blue==self.blue) end end
As a result I am getting an error in my code probably because != has not been defined.
The second one probably messes up with Array Class and to_s method!!
It looks probably something like this:class Array def to_s(arr) text='['+arr.join(',')+']' end
PLEASE DON'T DO THAT. Create new methods , but do not modify existing!!
Tomasz
-
Overriding common class methods that EVERYONE uses is irresponsible. Ditto.
Play nice.
Todd
-
Operator overloading in any language is a lot of rope to hang yourself with. And its always the guy who just discovered that language feature that goes postal with it.
On a related note, I got caught badly while writing some Ruby C extension last month whereby on Win32, ruby.h quietly #defines fopen() and fclose() to be something completely different! Just insane.
Adam
Advertisement