Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added news/4.41/images/foreachexample.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions news/4.41/jdt.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,36 @@ When navigating to a declaration, implementation, or method within the same edit

This makes it easier to inspect implementations, compare code, and work with multiple locations in parallel without losing your current position.

### Enhanced For-loop to ForEach Quick Assist

<details>
<summary>Contributors</summary>

[Ivan Gualandri](https://github.com/inuyasha82)
[Carsten Hammer](https://github.com/carstenartur)
</details>

With this new quick assist, on a enhanced for-loop like the following:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
With this new quick assist, on a enhanced for-loop like the following:
With this new quick assist, on an enhanced for-loop like the following:


```java
for (String adj : list) {
System.out.println(adj);
}
```

if the list item is an Iterable object a new option is added: `Convert Enhanced for loop to forEach`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if the list item is an Iterable object a new option is added: `Convert Enhanced for loop to forEach`.
if the list item is an `Iterable` object, a new option is available: `Convert Enhanced 'for' loop to 'forEach'`.

The text of the option should look exactly like it does in the IDE, where I think there are ' characters that are missing.

This let the user to convert the loop above, with a `forEach` statement:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This let the user to convert the loop above, with a `forEach` statement:
This converts the loop above, with a `forEach` statement:


```java
list.forEach(adj -> {
System.out.println(adj);
});
```
Below an animation of the new quick assist:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Below an animation of the new quick assist:
Below is an animation of the new quick assist:


![Foreach conversion in action](images/foreachexample.gif)


<!--
---
## Java Views and Dialogs
Expand Down