I declare a field in companion object, so it will be known in the functions in the companion object.
something like this:
class ProgramStructure {
companion object {
var index = 0
fun inc(){
index++
}
}
}
Everything work perfect, but when I debugging it I can't see the value of "index". How can I see the value?
Thanks
I assume you are using IntelliJ IDEA.
Since index
is neither a local variable nor a field of the current instance, there's no straightforward way to see its value in the debugger.
If you need to evaluate index
once, you can use the Evaluate Expression action (the default keyboard shortcut is Alt+F8), which is available in the debug window:
Then type index
:
Another way to evaluate an expression is to Alt+click it in the editor, or select it and press Ctrl/Cmd+Alt+F8.
If you want to watch the index
values over time, consider adding a watch (New Watch, Insert in the debug window, or from the Evaluate Expression dialog), and here's how it looks with the watch:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With