JaroslavTulach at 17:32, 24 September 2013 - 2013-09-24 17:32:44

←Older revision Revision as of 17:32, 24 September 2013
Line 54: Line 54:
</source>
</source>
-
[[NetBeans]] own source code sticks (and will stick) with [[JDK]]7 for a while. As such I don't have much chances to use [[lambdas]], but I can say I can write [[lambdas]], now!
+
[[NetBeans]] own source code sticks (and will stick) with [[JDK]]7 for a while. As such I don't have much chances to use [[lambdas]], but I can say I can write [[lambdas]], now (of course only with massive help from the [[NetBeans]] IDE)!
-
Just one thing I don't understand? Why people claim [[NetBeans]] IDE does not understand [[lambdas]]?
+
Just one thing I don't understand: Why people claim [[NetBeans]] IDE does not understand [[lambdas]]?

JaroslavTulach at 17:31, 24 September 2013 - 2013-09-24 17:31:55

←Older revision Revision as of 17:31, 24 September 2013
Line 54: Line 54:
</source>
</source>
-
[[NetBeans]] own source code sticks (and will stick) with [[JDK]]7. As such I don't have much chances to use [[lambdas]], but I can say I can write [[lambdas]], now!
+
[[NetBeans]] own source code sticks (and will stick) with [[JDK]]7 for a while. As such I don't have much chances to use [[lambdas]], but I can say I can write [[lambdas]], now!
Just one thing I don't understand? Why people claim [[NetBeans]] IDE does not understand [[lambdas]]?
Just one thing I don't understand? Why people claim [[NetBeans]] IDE does not understand [[lambdas]]?

JaroslavTulach at 17:31, 24 September 2013 - 2013-09-24 17:31:25

←Older revision Revision as of 17:31, 24 September 2013
Line 40: Line 40:
[[Image:Lambdas.png]]
[[Image:Lambdas.png]]
-
after applying the hint I finally got correct [[lambdas]] syntax:
+
after applying the hint I finally got [[lambda]] syntax right:
<source lang="java">
<source lang="java">

JaroslavTulach at 17:30, 24 September 2013 - 2013-09-24 17:30:21

←Older revision Revision as of 17:30, 24 September 2013
Line 1: Line 1:
-
[[Lambdas]] are [[Java]] implementation of [[Closures]] and are coming with [[JDK]]8.
+
[[Lambdas]] are [[Java]] implementation of [[Closures]] and are coming in [[JDK]]8.
== Don't Know the Syntax? ==
== Don't Know the Syntax? ==

JaroslavTulach at 17:29, 24 September 2013 - 2013-09-24 17:29:17

←Older revision Revision as of 17:29, 24 September 2013
Line 37: Line 37:
and suddenly a hint appeared:
and suddenly a hint appeared:
 +
 +
[[Image:Lambdas.png]]
 +
 +
after applying the hint I finally got correct [[lambdas]] syntax:
 +
 +
<source lang="java">
 +
public class LambdaTest {
 +
static void doRun(Runnable r) {
 +
r.run();
 +
}
 +
 +
public static void main(String... args) {
 +
doRun(() -> System.out.println("Hello World!"));
 +
}
 +
}
 +
</source>
 +
 +
[[NetBeans]] own source code sticks (and will stick) with [[JDK]]7. As such I don't have much chances to use [[lambdas]], but I can say I can write [[lambdas]], now!
 +
 +
Just one thing I don't understand? Why people claim [[NetBeans]] IDE does not understand [[lambdas]]?

JaroslavTulach at 17:24, 24 September 2013 - 2013-09-24 17:24:16

←Older revision Revision as of 17:24, 24 September 2013
Line 23: Line 23:
</source>
</source>
-
No luck either. I gave up and rewrote the code to old good inner class syntax:
+
No luck either. I gave up and rewrote the code to old good verbose but familiar inner class syntax:
<source lang="java">
<source lang="java">
-
doRun(new Runnable() { public void run() {
+
public static void main(String... args) {
-
System.out.println("Hello World!");
+
doRun(new Runnable() {
-
}});
+
@Override
 +
public void run() {
 +
System.out.println("Hello World!");
 +
}
 +
});
 +
}
</source>
</source>
and suddenly a hint appeared:
and suddenly a hint appeared:

JaroslavTulach: New page: Lambdas are Java implementation of Closures and are coming with JDK8. == Don't Know the Syntax? == Yesterday I had a duty at NetBeans JavaOne2013 booth. Somebody ... - 2013-09-24 17:21:09

New page: Lambdas are Java implementation of Closures and are coming with JDK8. == Don't Know the Syntax? == Yesterday I had a duty at NetBeans JavaOne2013 booth. Somebody ...

New page

[[Lambdas]] are [[Java]] implementation of [[Closures]] and are coming with [[JDK]]8.

== Don't Know the Syntax? ==

Yesterday I had a duty at [[NetBeans]] [[JavaOne2013]] booth. Somebody asked whether [[NetBeans]] support [[lambda]]. ''Sure, [[NetBeans]] 7.4 do!'' was my answer. But how to demonstrate that? I tried:

<source lang="java">
class LamdaTest {
static void doRun(Runnable r) {
r.run();
}

public static void main(String... args) {
doRun({ System.out.println("Hello World!"); });
}
}
</source>

it did not compile. Then I tried to change the lambda line to:

<source lang="java">
doRun( => { System.out.println("Hello World!"); });
</source>

No luck either. I gave up and rewrote the code to old good inner class syntax:

<source lang="java">
doRun(new Runnable() { public void run() {
System.out.println("Hello World!");
}});
</source>

and suddenly a hint appeared: