#MOOC WTF?
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
@cold storm
check the question again
its not which number .count returns
How many numbers does the stream take to the lambda-expression
"i -> i > 10"
0 numbers pass that expression
if any passed that, they would be taken by count anyway
how many numbers are at that point of execution
yes
Same doubt I had
Paste the code here please
Issue is already solved man, thanks tho
I mean, let me show you something
#chit-chat message
So paste the code please
List<Integer> numbers = new ArrayList<>();
for (int i = 0; i < 10; i++) {
numbers.add(i);
}
long howManyNumbers = numbers.stream()
.filter(i -> i < 4)
.map(i -> i * 2)
.filter(i -> i > 10)
.count();
System.out.println("Numbers: " + howManyNumbers);
Detected code, here are some useful tools:
[WARNING] The code couldn't end properly...
Problematic source code:
List<Integer> numbers = new ArrayList<>();```
Cause:
The code doesn't compile:
cannot find symbol
symbol: class List
location: class
cannot find symbol
symbol: class ArrayList
location: class
Remaining code:
```java
for (int i = 0; i < 10; i++) {
numbers.add(i);
}
long howManyNumbers = numbers.stream()
.filter(i -> i < 4)
.map(i -> i * 2)
.filter(i -> i > 10)
.count();
System.out.println("Numbers: " + howManyNumbers);```
## System out
[Nothing]
import java.util.*;
List<Integer> numbers = new ArrayList<>();
for (int i = 0; i < 10; i++) {
numbers.add(i);
}
long howManyNumbers = numbers.stream()
.filter(i -> i < 4)
.map(i -> i * 2)
.filter(i -> i > 10)
.count();
System.out.println("Numbers: " + howManyNumbers);
this output wont help with the question
Detected code, here are some useful tools:
System out
Numbers: 0
nice question title
so it prints 0
I had already run the output if thats what you wanted to show
yeah but thats not the question lmao
I know that it passes nothing
just wanted to show jshell 😦
the question is not about the output, its slightly a tricky question
I know, it wasnt helpful here though :/
jshell flex
yeah, they shouldnt add the call to count, that just makes it confusing
yes
verbally tricky imo, code wise it was clear I just didn't understand exactly what they wanted
read
"take" can be interpreted in many ways for that question, which it did
imo take in that sentence is pretty clear
but yeah might be confusing, cant really tell
and the question overall is actually clear, but the brain easily automatically skims through it and just sees that .count() and guesses thats the question
Wait a minute the answer should be 4
but they didnt
I think the question is pretty fine
you going to walkthrough the code with your brain instead of simply running the code to see what it does
0, 2, 4, 6
yeah true
true, I was considering them before multiplication for some reason