takeWhile() works like take(), but it instead takes a lambda expression as a parameter. The first items are emitted downstream, until that lambda expression evaluates to true. At that point, all remaining items are ignored.

In this case, we take "all" items while they are odd. Since the 2 is the first even item, all items starting with 2 get ignored, so we only print 1.

You can learn more about this in:
Run Edit