News for hackers. Stuff that matters.
Re:An Introduction to JavaScript's "this" by jmtulloss on Saturday September 26, 2009 @10:40PM (#846433)
sorry, that was typed up pretty quickly, and I'm not a rubyist... care to correct it?
Re:An Introduction to JavaScript's "this" by jhancock on Saturday September 26, 2009 @11:35PM (#846490)

  class HotDog
         @condiments
         def getCondiments
              return @condiments // @condiments is an instance variable of an instance of HotDog
         end
    end
note the mod to both the ivar def and the comment. You also do not need the initial ivar "definition" as ruby defines them on the fly when they are first referenced.
Re:An Introduction to JavaScript's "this" by xtho on Sunday September 27, 2009 @12:51AM (#846540)
No,

The first @condiments would define a class variable.

    class HotDog
        attr_accessor :condiments
    end
Or for Java-socialized folks:

    class HotDog
         def initialize
             @condiments = nil
         end

         def getCondiments
              return @condiments
         end
    end
Re:An Introduction to JavaScript's "this" by jhancock on Sunday September 27, 2009 @02:48AM (#846606)
oops, sorry. yes, the first line would define a "class instance" variable.

btw, I didn't show the attr_accessor meta-programming sine it hides the guts of the excercise.

Re:An Introduction to JavaScript's "this" by jmtulloss on Sunday September 27, 2009 @06:46AM (#846748)
I made some corrections. How's it look now?
Re:An Introduction to JavaScript's "this" by jhancock on Sunday September 27, 2009 @04:08PM (#847203)
I posted a bit too quick and too late at night. See corrections on this thread.