Re: How can I do this -- method chaining

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 29, 2008 3:26 PM, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote:

> Nathan Nobbe schreef:
> > On Jan 29, 2008 3:02 PM, Stut <stuttle@xxxxxxxxx> wrote:
> >
> >> Why? What exactly do you think you're saving by not putting the
> >> instance in a variable? I can't think of one good reason to do this.
> >>
> >
> > its an esthetic thing; and besides the simple factory method is an
> > easy workaround to achieve it.
> > as the article that, Eric, posted mentioned, other languages have
> > such support; ie javascript:
> > function Test() {}
> > Test.prototype = { doSomething : function() { alert('hello'); } }
>
>        ^^ !!!! prototypal not class-based inheritance, orange meet apple.
>

i never said it was :P

besides which this is a dereferenced call and not method chaining,
> if you want method chaining in JS you'll have to do extra work (i.e. use
> 'return this;')
> different strokes or something.
>

this example was to illustrate that in other languages, such as javascript,
an object
method can be invoked directly from an instance returned by a call to new
(which is
really what were talking about in this thread).  whereas, in php, as weve
seen today,
youll have to implement a workaround.

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux