How to use Breakpoint Condition?

Hello,

using the code bellow, I tried to set a conditional breakpont with the condition    y==4  . There is an error "Can not resolve symbol 'y'".  Is this a bug or the condtion is wrong?

object ScalaTeste03 {
  def main(args: Array[String]): Unit = {
    for ( y <- 1 to 10 ) {
       println(y)
    }
  }

3 comments
Comment actions Permalink

the amount of answers necessary to make you understand why that does not work is rather big. it's much easier to tell you this: drop some frames, look at the stack and you will understand.

0
Comment actions Permalink

Thanks for answering.

Sorry.. I couldn't understand.... conditional breakpoints do not work or the condition "y==4" doesn't work?

Dropping frames I found:   (breakpoint) <- ByOne <- Inclusive <- (my code)

I couldn't find how to look at the stack.

Marcos

>> the amount of answers necessary to make you understand why that does not  work is rather big. it's much
>> easier to tell you this: drop some frames,  look at the stack and you will understand.

0
Comment actions Permalink

as short and precise as possible:
a for loop in scala is equal to calling foreach. foreach applies the collections content to a function. the function1 trait has a method "apply" with one parameter which is named "v1" (for "value 1"). so the variable "e" does not exist inside the function. it's called "v1" there.

the compiler takes your "local loop variable" and puts it into the function, which leads to it being renamed.

0

Please sign in to leave a comment.