StreamToLoop: support Optional unwrap if possible

This commit is contained in:
Tagir Valeev
2016-12-09 15:17:26 +07:00
parent ae273b6c24
commit 8e128b7f32
27 changed files with 425 additions and 90 deletions
@@ -13,7 +13,7 @@ public class Main {
count++;
}
}
return count == 0 ? OptionalDouble.empty() : OptionalDouble.of((double) sum / count);
return count > 0 ? OptionalDouble.of((double) sum / count) : OptionalDouble.empty();
}
public static void main(String[] args) {