Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDT could not support java lambda forEach of list syntax? #1290

Closed
river2017 opened this issue Aug 6, 2021 · 3 comments
Closed

GDT could not support java lambda forEach of list syntax? #1290

river2017 opened this issue Aug 6, 2021 · 3 comments

Comments

@river2017
Copy link

river2017 commented Aug 6, 2021

Hello,
I pust some code snippet of groovy into GDT( The Groovy Development Tools ) to test java lambda function,but GDT can not compile it.
I need some help.

public class Test1 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("123456");
        list.forEach(t->{System.out.println("r="+t)})
    }
}

The error msg is :

Multiple markers at this line (  list.forEach(t->{System.out.println("r="+t)}) )
	- Groovy:expecting '}', found '->' @ line 7, 
	 column 23
@eric-milles
Copy link
Member

@eric-milles
Copy link
Member

You could also write your test this way:

class Test {
  static main(args) {
    List<String> list = ['123456']
    list.forEach { println "r=$it" }
  }
}

@river2017
Copy link
Author

Great! thank u!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants