Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin3!goblin1!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!newsfeed3.funet.fi!newsfeeds.funet.fi!news.helsinki.fi!.POSTED!not-for-mail From: Jussi Piitulainen Newsgroups: comp.lang.java.programmer Subject: Re: How to check if the n-th part of an array of Strings exist? Date: 27 Oct 2011 16:55:26 +0300 Organization: University of Helsinki Lines: 30 Sender: jpiitula@ruuvi.it.helsinki.fi Message-ID: References: <4ea6e340$0$6580$9b4e6d93@newsspool3.arcor-online.net> <4ea95fbd$0$631$426a74cc@news.free.fr> NNTP-Posting-Host: ruuvi.it.helsinki.fi Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: oravannahka.helsinki.fi 1319723725 19184 128.214.205.65 (27 Oct 2011 13:55:25 GMT) X-Complaints-To: usenet@oravannahka.helsinki.fi NNTP-Posting-Date: Thu, 27 Oct 2011 13:55:25 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9244 Mayeul writes: > On 27/10/2011 15:09, Tim Slattery wrote: > > Eric Sosman wrote: > > > >> On 10/27/2011 3:20 AM, Jussi Piitulainen wrote: > >>> Wojtek writes: > >>> > >>>> You check for the number of "slots" in the array: > >>>> > >>>> if ( index>= 0&& index< part.length ) > >>>> do something with part[index] > >>>> else > >>>> error(); > >>> > >>> Shame that (0<= index< part.length) means something useless instead. > >> > >> Be thankful that its meaning in Java is more useful than in C. > > > > Please explain that. I'm probably wrong, but I'd think they'd be the > > same. > > > > Evaluate one of the comparisons (not positive which one), > > resulting in a boolean. Convert the boolean to a number to do the > > other comparison. Not very useful. > > I'd wager that refusing to compile is more useful than meaning > something useless and confusing, therefore errors-prone. Indeed, I missed that. I'll agree that Java's interpretation is less harmful than C's. Python gets this right.