Skip to content

Instantly share code, notes, and snippets.

@npryce
Created January 26, 2019 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npryce/437e32e8184c5aa782422ca84ac48d00 to your computer and use it in GitHub Desktop.
Save npryce/437e32e8184c5aa782422ca84ac48d00 to your computer and use it in GitHub Desktop.
string-char-to-int-pitfall

In Kotlin String.toInt() and Char.toInt() do very different things.

>>> "9".toInt()
9
>>> '9'.toInt()
57
>>> 

The former parses the String to an Int. The latter returns the Unicode codepoint value of the character.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment