Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: in1To10 Date: Sat, 09 Aug 2014 17:02:56 -0400 Organization: A noiseless patient Spider Lines: 23 Message-ID: References: <0c8de66a-429a-4697-b575-35f37a7b6882@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 9 Aug 2014 21:03:02 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="4635"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CePjv97TS+bK9R92ZQSa0" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: Cancel-Lock: sha1:5hZPRGe19AaCPrSinl8LMLdX92E= Xref: csiph.com comp.lang.java.programmer:29601 On 8/9/2014 4:56 PM, Marcel Mueller wrote: > On 09.08.14 21.12, cdalten@gmail.com wrote: >> Now upon googling the solutions, I saw some people use >> if(outsideMode == false) >> if(outsideMode == true) >> >> instead of using if(outsideMode == false)/else(outsideMode == true). >> >> Would both catch all the cases? If not, which one would? > > There is almost always more than one solution for a given problem. > Since booleans can only be true or false the second if (after else) is > superfluous. And you also could simply write > return (n >= 1 && n <= 10) ^ outsideMode; > > The solutions might differ in execution speed or code length and style > but as long this is not part of the task it makes no difference. Unfortunately, this cleaned-up version does not solve the problem as specified. (Hint: What is `in1To10(1,true)'?) -- esosman@comcast-dot-net.invalid