Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Steven Simpson Newsgroups: comp.lang.java.programmer Subject: Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? Date: Wed, 02 Jan 2013 21:46:00 +0000 Organization: A noiseless patient Spider Lines: 14 Message-ID: References: <9f030e71-96ab-4ead-9690-4369f4a19aa9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="0d771e3708e29ef01409ed69429633ae"; logging-data="22601"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VUDyL+LVIbxsOBdVcE/okdiUfHGTMtpI=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: Cancel-Lock: sha1:W1L6PuVBaag+pVQDWsaOSAGx6aY= Xref: csiph.com comp.lang.java.programmer:20882 On 02/01/13 19:31, Saxo wrote: >> int sum = ints.reduce(0, (x, y) -> x + y); > Nice, but it does not compile with me. I use IDEA 12 and the lambda-8-b69-windows-i586-17_dec_2012 JDK. Seems like reduce does not exist in Iterator or Collection!? I figured, if forEach is on Collection, reduce likely would be too. I did try to have a look for it in source, but wasn't sure if I had the right branch. I also didn't find the javadoc on-line. Based on the source, try: ints.stream().reduce(0, (x, y) -> x + y) -- ss at comp dot lancs dot ac dot uk