In Scala language, I want to write a function that yields odd numbers within a given range. The function prints some log when iterating even numbers. The first version of the fu
def IWantToDoSomethingSimilar(N: Int) = for { n <- 0 until N if n % 2 != 0 || { println("skip even number " + n); false } } yield n
Using filter instead of a for expression would be slightly simpler though.
filter
for