X-Received: by 10.224.190.193 with SMTP id dj1mr26520889qab.6.1357176930715; Wed, 02 Jan 2013 17:35:30 -0800 (PST) Received: by 10.49.58.238 with SMTP id u14mr7575148qeq.13.1357176930681; Wed, 02 Jan 2013 17:35:30 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!ee4no12352722qab.0!news-out.google.com!k2ni4226qap.0!nntp.google.com!ee4no12472729qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Wed, 2 Jan 2013 17:35:30 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 69.28.149.29 References: <9f030e71-96ab-4ead-9690-4369f4a19aa9@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Why is that in JDK8: value used in lambda expression shuld be effectively final? From: Lew Injection-Date: Thu, 03 Jan 2013 01:35:30 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.java.programmer:20893 Steven Simpson wrote: > 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 'forEach' is not on Collection. It's on Collection's parent type. > 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: Javadoc for Java 8 is on line: http://download.java.net/jdk8/docs/api/index.html Not hard to find, but it doesn't contain the information you wanted. > ints.stream().reduce(0, (x, y) -> x + y) http://datumedge.blogspot.com/2012/06/java-8-lambdas.html gives a brief overview. -- Lew