The next guy "sucks", I saw ternary used in ruby so just looked it up on google.
I will use the [] for conditional execution, very educational.
It would probably need commenting, but if you know what it does, how it does it 
is only a google search away.

> Date: Thu, 16 Apr 2009 14:19:50 -0700
> Subject: [jQuery] Re: Shorten the JQuery code
> From: michaell...@gmail.com
> To: jquery-en@googlegroups.com
> 
> 
> Guess it depends on who the next guy is :)
> 
> On Apr 16, 2:16 pm, "Andy Matthews" <li...@commadelimited.com> wrote:
> > I'd be careful with code like that. It is terse, and very elegant, but not
> > all that readable from a "coding for the next guy" mentality.
> >
> >   _____  
> >
> > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
> > Behalf Of Joseph Le Brech
> > Sent: Thursday, April 16, 2009 4:12 PM
> > To: jquery-en@googlegroups.com
> > Subject: [jQuery] Re: Shorten the JQuery code
> >
> > I'm impressed by the [] brackets, does that eval() the 'hide' and 'show'
> > strings?
> >
> >
> >
> > > Date: Thu, 16 Apr 2009 14:08:09 -0700
> > > Subject: [jQuery] Re: Shorten the JQuery code
> > > From: michaell...@gmail.com
> > > To: jquery-en@googlegroups.com
> >
> > > $('#no-defs')[$('.def').length==0?'show':'hide']();
> >
> > > On Apr 16, 1:54 pm, MorningZ <morni...@gmail.com> wrote:
> > > > There isn't much you can do with that since you can't conditionally
> > > > code in ".show" or ".hide" unless you made a plugin to pass in a true/
> > > > false parameter and decide in the plugin, for instance
> >
> > > > $("#no_defs").conditionalShow($('.def').length == 0);
> >
> > > > On Apr 16, 4:27 pm, Dragon-Fly999 <dragon-fly...@hotmail.com> wrote:
> >
> > > > > Could someone tell me how to shorten the following code? Thanks.
> >
> > > > >           if ($('.def').length == 0) {
> > > > >             $('#no-defs').show();
> > > > >           }
> > > > >           else {
> > > > >             $('#no-defs').hide();
> > > > >           }
> >
> >   _____  
> >
> > Surfing the web just got more rewarding. Download the New Internet Explorer
> > 8 <http://extras.uk.msn.com/internet-explorer-8/?ocid=T010MSN07A0716U>  

_________________________________________________________________
Beyond Hotmail — see what else you can do with Windows Live.
http://clk.atdmt.com/UKM/go/134665375/direct/01/

Reply via email to