#MOOC WTF?

1 messages · Page 1 of 1 (latest)

wooden condor
#

how can it be 4?

ripe wigeonBOT
#

<@&987246399047479336> please have a look, thanks.

wooden condor
#

@cold storm

crystal wave
#

check the question again

#

its not which number .count returns

#

How many numbers does the stream take to the lambda-expression "i -> i > 10"

wooden condor
#

0 numbers pass that expression

#

if any passed that, they would be taken by count anyway

crystal wave
#

not "pass"

#

how many does that take

wooden condor
#

what does take mean in this context?

#

as in, how many are previewed?

crystal wave
#

how many numbers are at that point of execution

wooden condor
#

okay, I see. thank you, then 0, 1, 2, 3

#

so 4

crystal wave
#

yes

cold storm
limber sphinx
wooden condor
limber sphinx
cold storm
#

#chit-chat message

limber sphinx
#

So paste the code please

wooden condor
# limber sphinx 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);
ripe wigeonBOT
# wooden condor ```java List<Integer> numbers = new ArrayList<>(); for (int i = 0; i < 10; i++) ...

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]
limber sphinx
#
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);
crystal wave
#

this output wont help with the question

ripe wigeonBOT
stuck tapir
#

nice question title

limber sphinx
#

so it prints 0

wooden condor
#

I had already run the output if thats what you wanted to show

crystal wave
wooden condor
#

I know that it passes nothing

limber sphinx
cold storm
#

the question is not about the output, its slightly a tricky question

crystal wave
wooden condor
#

jshell flex

crystal wave
#

but question got already resolved

#

so its fine

crystal wave
wooden condor
wooden condor
crystal wave
#

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

limber sphinx
#

Wait a minute the answer should be 4

crystal wave
#

yea

#

and it is

limber sphinx
#

They should have asked what does it print

#

something like that

crystal wave
#

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

karmic pewter
crystal wave
#

yeah true

wooden condor