Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39011

Re: Java missing return statement question...

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Java missing return statement question...
Date Thu, 18 Jul 2019 13:47:31 -0400
Organization A noiseless patient Spider
Lines 42
Message-ID <qgqbbl$d98$1@dont-email.me> (permalink)
References <67615856-0be2-4c3f-ae4c-c9f3cb379451@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Thu, 18 Jul 2019 17:47:33 -0000 (UTC)
Injection-Info reader02.eternal-september.org; posting-host="5bccda0ab423153d5b2c14eeb22367d9"; logging-data="13608"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YTS/BeGhUrOTfz88w+86W"
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
Cancel-Lock sha1:Tlsb3O/x/dAaqQ28RIpijW/ID0k=
In-Reply-To <67615856-0be2-4c3f-ae4c-c9f3cb379451@googlegroups.com>
Content-Language en-US
Xref csiph.com comp.lang.java.programmer:39011

Show key headers only | View raw


On 7/18/2019 9:29 AM, cdalten@gmail.com wrote:
> I don't quite understand why something like the following gives a missing return statement.

     Andreas Leitgeb has already answered your main question.  I'd
just like to point out one additional oddity:

>    if (noDoubles == true) {

     You begin with the boolean `noDoubles', which (necessarily) has one
of the values `true' or `false'.  You want to find out whether the value
is `true', so you compare it to `true' -- and since the comparison
produces either `true' or `false', you have made no "progress."  That
is, you *still* have a value that is either `true' or `false', exactly
as you did before making the comparison.  What next?

     You could continue by writing

	if ((noDoubles == true) == true) {

... but you're still in the same situation, so onward to

	if (((noDoubles == true) == true) == true) {

... but that's still no help, either.  You could try something
along the lines of

	if ((((noDoubles == true) == false) != true) == true) {

... but somehow I don't see this line of attack getting anywhere.
"Anywhere useful," that is.

     Instead, consider

	if (noDoubles) {

... and your Note To Self For Future Reference should be: "It may,
rarely, make sense to compare two boolean values, but comparing a
boolean to a constant never makes sense."

-- 
esosman@comcast-dot-net.invalid
Five hundred fifty-two days to go.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Java missing return statement question... cdalten@gmail.com - 2019-07-18 06:29 -0700
  Re: Java missing return statement question... Andreas Leitgeb <avl@logic.at> - 2019-07-18 13:44 +0000
    Re: Java missing return statement question... cdalten@gmail.com - 2019-07-18 06:54 -0700
  Re: Java missing return statement question... Eric Douglas <e.d.programmer@gmail.com> - 2019-07-18 07:51 -0700
  Re: Java missing return statement question... Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-07-18 13:47 -0400

csiph-web