Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!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 17:34:56 -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 21:28:50 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="6a6a291fa7e9c0bd872c1a9cbe2b371d"; logging-data="12974"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vhqMOyruguC+qxd8dVnV5EirvNVD5aug=" 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:0kIBhLBvth6mjEi1srjjZ82IiiQ= Xref: csiph.com comp.lang.java.programmer:19308 On 10/13/2012 04:33 PM, Wanja Gayk wrote: > In article, > donkey@fredriksson.dy.fi says... > >>> if (server.getConnectionType() == ConnectionType.ACTIVE) >>> ftp.enterLocalActiveMode(); >>> else >>> ftp.enterLocalPassiveMode(); >>> >>> but I want to do: >>> >>> (server.getConnectionType() == ConnectionType.ACTIVE) ? >>> ftp.enterLocalActiveMode() : ftp.enterLocalPassiveMode(); >> >> Why do you want to use an assignment statement without need or means to >> assign anything to anywhere? What's the rationale? > > I think the author is questioning, why this statement is only usable as > an assignment statement. > > Yes you don't it, as you could refactor the code like this: > > ftp.enterMode( > server.getConnectionType() == ACTIVE ? Mode.LOCAL_ACTIVE > : Mode.LOCAL_PASSIVE > ); > > But still I fancy the idea to be able to write: > > purse.isEmpty() ? goHome() : goToTheMovies(); > as a shorthand for: > if (purse.isEmpty()) goHome(); else goToTheMovies(); > > What would be wrong about that? > According to others in parallel threads it's all wrong. I agree it would be pretty.