sketchucation logo sketchucation
    • Login
    ๐Ÿค‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Irritating Class methods modification

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 475 Views 3 Watching
    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

      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

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

        Play nice.

        Todd

        1 Reply Last reply Reply Quote 0
        • AdamBA Offline
          AdamB
          last edited by

          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
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement