Some questions about for { ... if ... } yield

hi all,
I’m a newcomer, when I read found " for / yield " may have problem, for example:
following code:
scala> val u = for ( s<- “hello” ) yield s.toUpper;
the result is :
u: String = HELLO
the result is right. but when I add if guard:
scala> val u = for ( s<- “hello” if s != ‘e’ ) yield s.toUpper;
the result is:
u: String = hllo

so, why? The result should be “HLLO”, because yield has toUpper them.

could any one help me?
thank you advanced:wink:

I just tried this and got HLLO
Perhaps you had a typo somewhere?

regards,
Siddhartha

1 Like

Thanks a lot for your answer. It’s not typo somewhere, I found its complier a bug of scala-2.13.0.M5:

We may report this bug to scala complier developer team :slight_smile:

1 Like

great catch! fix in progress at https://github.com/scala/scala/pull/7367

thank you:)