Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29629
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: in1To10 |
| Date | 2014-08-10 11:33 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <ls83bt$42j$1@dont-email.me> (permalink) |
| References | <0c8de66a-429a-4697-b575-35f37a7b6882@googlegroups.com> <ls61to$agh$1@news.albasani.net> <ls62a5$4gr$1@dont-email.me> <ls64li$gf1$1@news.albasani.net> <c4pfluF3slmU1@mid.individual.net> |
On 8/10/2014 10:59 AM, Torsten Kirschner wrote:
> Den 09.08.2014 23:43, skrev Marcel Mueller:
>> On 09.08.14 23.02, Eric Sosman wrote:
>>> Unfortunately, this cleaned-up version does not solve the
>>> problem as specified. (Hint: What is `in1To10(1,true)'?)
>>
>> Oops, you are right, I read a bit fast. 1 and 10 should always return true.
>
> So...
>
> static boolean in1To10(int n, boolean outsideMode) {
>
> if (n == 1 || n == 10)
> return true;
>
> return (n > 1 && n < 10) ^ outsideMode;
> }
Looks right to me. It could be abbreviated:
return n == 1 || n == 10 || ((n > 1 && n < 10) ^ outsideMode);
... but to my eye the clearest expression would be something like:
return outsideMode
? (n <= 1 || n >= 10)
: (n >= 1 && n <= 10);
(I've seen coding standards that discourage the ?: operator on the
grounds that "it's confusing," but to me that seems bogus. People who
write such standards must hold a poor opinion of the people who will
have to follow them, and I don't want to work with people who have such
a poor opinion of me. Hiring a Java programmer who's confused by ?:
would be like hiring a tone-deaf violinist.)
--
esosman@comcast-dot-net.invalid
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
in1To10 cdalten@gmail.com - 2014-08-09 12:12 -0700
Re: in1To10 Jeff Higgins <jeff@invalid.invalid> - 2014-08-09 15:58 -0400
Re: in1To10 Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-09 16:13 -0400
Re: in1To10 Marcel Mueller <news.5.maazl@spamgourmet.org> - 2014-08-09 22:56 +0200
Re: in1To10 Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-09 17:02 -0400
Re: in1To10 Marcel Mueller <news.5.maazl@spamgourmet.org> - 2014-08-09 23:43 +0200
Re: in1To10 Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-09 19:49 -0400
Re: in1To10 Torsten Kirschner <torsten@kirschner.no> - 2014-08-10 16:59 +0200
Re: in1To10 Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-10 11:33 -0400
Re: in1To10 Torsten Kirschner <torsten@kirschner.no> - 2014-08-11 22:23 +0200
Re: in1To10 Gene Wirchenko <genew@telus.net> - 2014-08-12 11:10 -0700
Re: in1To10 Arne Vajhøj <arne@vajhoej.dk> - 2014-08-19 16:54 -0400
Re: in1To10 Gene Wirchenko <genew@telus.net> - 2014-08-20 10:36 -0700
Re: in1To10 Arne Vajhøj <arne@vajhoej.dk> - 2014-08-19 16:53 -0400
Re: in1To10 cdalten@gmail.com - 2014-08-09 18:35 -0700
Re: in1To10 Jeff Higgins <jeff@invalid.invalid> - 2014-08-09 22:13 -0400
Re: in1To10 Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-09 22:23 -0400
Re: in1To10 Jeff Higgins <jeff@invalid.invalid> - 2014-08-10 12:07 -0400
Re: in1To10 Mike Amling <mamling@chaff.us> - 2014-08-10 00:29 -0500
Re: in1To10 "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-08-10 13:53 +0100
Re: in1To10 Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-10 09:48 -0400
Re: in1To10 "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-08-10 15:01 +0100
Re: in1To10 Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-10 10:32 -0400
Re: in1To10 "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-08-10 15:53 +0100
Re: in1To10 lipska the kat <lipskathekat@example.com> - 2014-08-10 14:07 +0100
Re: in1To10, a simple test plan lipska the kat <lipskathekat@example.com> - 2014-08-10 16:43 +0100
Re: in1To10, a simple test plan Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-10 12:01 -0400
Re: in1To10, a simple test plan lipska the kat <lipskathekat@example.com> - 2014-08-10 17:41 +0100
Re: in1To10, a simple test plan Arne Vajhøj <arne@vajhoej.dk> - 2014-08-19 16:57 -0400
Re: in1To10 Roedy Green <see_website@mindprod.com.invalid> - 2014-08-12 02:59 -0700
csiph-web