Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Assigning void Date: Sat, 13 Oct 2012 21:35:11 -0400 Organization: A noiseless patient Spider Lines: 35 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 14 Oct 2012 01:35:13 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="ffb8f7085759b339c1002252b48331a4"; logging-data="27007"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18H/38+T0GEO30GFwI2KRTc" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 In-Reply-To: Cancel-Lock: sha1:9UZumb3xb4ahtDWHN72lRuUeKdU= Xref: csiph.com comp.lang.java.programmer:19321 On 10/13/2012 5:45 PM, Eric Sosman wrote: > On 10/13/2012 4:33 PM, Wanja Gayk wrote: >> [...] >> 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? > > (purse.isEmpty() > ? new Runnable() { > @Override > public void run() { > goHome(); > } > } > : new Runnable() { > @Override > public void run() { > goToTheMovies(); > } > } > ).doIt(); > > Problem solved! ... once the method name in the final line is changed from `doIt' to `run'. >Sigh< The perils of making "clarifying edits" without similar attention to proofreading ... -- Eric Sosman esosman@comcast-dot-net.invalid