Path: csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: Assigning void Date: Sat, 13 Oct 2012 15:03:10 -0400 Organization: A noiseless patient Spider Lines: 38 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 13 Oct 2012 18:57:05 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="6a6a291fa7e9c0bd872c1a9cbe2b371d"; logging-data="22548"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/I2WDX9l8hVgpgM/ToyJhvwP/hwsTi9gw=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20120925 Icedove/3.0.11 In-Reply-To: Cancel-Lock: sha1:VTuatnScDr70gPwj1aEhInd2k2U= Xref: csiph.com comp.lang.java.programmer:19287 On 10/13/2012 02:26 PM, Jeff Higgins wrote: > On 10/13/2012 01:05 PM, glen herrmannsfeldt wrote: >> Jeff Higgins wrote: >> >> (snip) >> >>>> (server.getConnectionType() == ConnectionType.ACTIVE) ? >>>> ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); >> >> (snip) >> >>> Others have pointed you to the specification. >>> I don't know why it can't be a shorthand if-then-else statement too. >> >> Java isn't C. >> >> Java allows for method calls that return a value to ignore the >> return value, but other expressions that don't use the value >> seem not to be allowed. >> >> 2+2; >> >> is legal C, but not Java. >> > C has its Rationale. > Java seems not to have a separate formal one. > 6.5.15 of the C Rationale only states > the construct is allowed and not why. > 15.25 of the Java Spec. only states > the construct is disallowed and not why. > Does it sound childish to ask why? Don't get me wrong. I understand that in both languages this construct is the conditional "operator". I'm asking only why it cannot also be shorthand for an if-then-else statement. boolean expression ? block : block