Hi Ngan, This question is probably more appropriate for the user's group[1], rather than the core development group. If you'll repost over there, there are a couple of things to point out in that stuff...
[1] http://groups.google.com/group/prototype-scriptaculous -- T.J. Crowder tj / crowder software / com www.crowdersoftware.com On Sep 10, 5:39 pm, Ngan <nganp...@gmail.com> wrote: > opps, i had typo. return should be: > > return { > initialize: initialize, > publicMethod: publicMethod > > } > > On Sep 10, 9:37 am, Ngan <nganp...@gmail.com> wrote: > > > > > Hi, I apologize if this question has been asked before. I've tried > > googling for this, but did find a good answer. > > > What's the best way to have private methods using prototype's > > Class.create? > > > I've tried... > > > var Worker = Class.create((function() { > > function initialize() { > > this.someVar = "var"; > > privateMethod(); > > } > > > function publicMethod() { > > privateMethod(); > > } > > > function privateMethod() { > > console.info(this.someVar); > > console.info(this) > > } > > > return { > > initialize: initialize > > }; > > > })()); > > > Running this will give me: > > console.info(this.someVar) #=> undefined > > console.info(this.someVar) #=> DOMWindow > > > However: > > aWorker = new Worker(); > > aWorker.publicMethod() #=> WORKS! > > > Thank you for your time! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---