// "Replace method call on lambda with lambda body" "true-preview" import java.util.*; import java.util.function.*; public class Test { public static void main(String[] args) { List list = new ArrayList<>(); if(list.isEmpty()) ((Consumer) x -> { System.out.println(x); list.add(x); }).accept("foo"); } }