简体   繁体   中英

convert function from java to kotlin

i tried pasing a java function in my Kotlin project and in automatically converted to Kotlin but still has an error.

 if (ch.toInt() >= 0x0660 && ch.toInt() <= 0x0669)
            ch -= 0x0660 - '0'
        else if (ch.toInt() >= 0x06f0 && ch.toInt() <= 0x06F9)
            ch -= 0x06f0 - '0'

it is giving error on the - "0" the error is: Non of the following functions can be called with the argument supplied

This is because kotlin doesn't type cast between char and int. You'll have to invoke .toInt() on the '0' like you already did with the char. The Int class only supports minus with the following types:

  • Byte
  • Short
  • Int
  • Long
  • Float
  • Double

    Link to the minus operator functions of Int .

    On the other side, Char only supports Char and Int when it comes to minus .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM