0

I am pasting the code below. The questions are written as a,b,c,d and e next to the codes. I could not try this by myself because I don't have an installed Android Studio currently. Can you explain?

        var pos = -1
        var ch = 0
        if (++pos < str.length) {        //a) here what is the value of pos?
                ch = str[pos].toInt()    //b) and here what is the value of pos?
            } else ch = -1

Next sample:

        var pos = -1
        var ch = 0
        if (pos++ < str.length) {        //c) here what is the value of pos?
                ch = str[pos].toInt()    //d) and here what is the value of pos?
            } else ch = -1
                                         //e) and at last what is the value of pos? 

Edit: Kotlin documentation is lacking for explaining the difference, I couldn't understand from there.

Anthon Santhez
  • 402
  • 1
  • 7
  • 13

0 Answers0