IDEA-161002 Support cases like if(...) { for(...) {...} } return false;

This commit is contained in:
Tagir Valeev
2016-09-13 12:21:27 +07:00
parent 9540aeb8c2
commit c29dc4e3a4
6 changed files with 97 additions and 8 deletions
@@ -0,0 +1,12 @@
// "Replace with anyMatch()" "true"
import java.util.Arrays;
import java.util.Objects;
public class Main {
boolean contains(String[][] haystack, String needle) {
if(haystack != null)
return Arrays.stream(haystack).filter(Objects::nonNull).flatMap(Arrays::stream).anyMatch(needle::equals);
return false;
}
}
@@ -0,0 +1,13 @@
// "Replace with anyMatch()" "true"
import java.util.Arrays;
import java.util.Objects;
public class Main {
boolean contains(String[][] haystack, String needle) {
if(haystack != null) {
return Arrays.stream(haystack).filter(Objects::nonNull).flatMap(Arrays::stream).anyMatch(needle::equals);
}
return false;
}
}
@@ -0,0 +1,15 @@
// "Replace with anyMatch()" "true"
public class Main {
boolean contains(String[][] haystack, String needle) {
if(haystack != null)
for (String[] row : haysta<caret>ck) {
if (row == null) continue;
for (String str : row) {
if (needle.equals(str))
return true;
}
}
return false;
}
}
@@ -0,0 +1,16 @@
// "Replace with anyMatch()" "true"
public class Main {
boolean contains(String[][] haystack, String needle) {
if(haystack != null) {
for (String[] row : haysta<caret>ck) {
if (row == null) continue;
for (String str : row) {
if (needle.equals(str))
return true;
}
}
}
return false;
}
}
@@ -0,0 +1,17 @@
// "Replace with anyMatch()" "false"
public class Main {
boolean contains(String[][] haystack, String needle) {
if(haystack != null) {
for (String[] row : haysta<caret>ck) {
if (row == null) continue;
for (String str : row) {
if (needle.equals(str))
return true;
}
}
System.out.println("Oops");
}
return false;
}
}