• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Irritating Class methods modification

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 3 Posters 475 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    tomasz
    last edited by 16 Mar 2008, 14:36

    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

    Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

    1 Reply Last reply Reply Quote 0
    • T Offline
      todd burch
      last edited by 17 Mar 2008, 02:34

      Overriding common class methods that EVERYONE uses is irresponsible. Ditto.

      Play nice.

      Todd

      1 Reply Last reply Reply Quote 0
      • A Offline
        AdamB
        last edited by 17 Mar 2008, 06:19

        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

        Developer of LightUp Click for website

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          1/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement