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 endAs 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(',')+']' endPLEASE 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better ๐
Register LoginAdvertisement