Can an integer in Kotlin be equal to an math expression?
问题 I am making a program that solves a math expression, for example, 2+2. Can I set an integer equal to something like this: val input = "2+2" input.toInt() 回答1: Kotlin doesn't have any built in ways for evaluating arbitrary expressions. The toInt function can only parse a String containing a single whole number (it's just a wrapper for Integer.parseInt). If you need this functionality, you'll have to parse and evaluate the expression yourself. This problem is no different than having to do it