什么是Kotlin中的指数运算符.我认为它会,**但它似乎在我的代码中引发错误.
when (pendingOperation) {
"=" -> operand1 = value
"÷" -> operand1 = if (value == 0.0) {
Double.NaN // handle attempt to divide by zero
} else {
operand1!! / value
}
"x" -> operand1 = operand1!! * value
"?" -> operand1 = operand1!! - value
"+" -> operand1 = operand1!! + value
"a^b" -> operand1 = operand1!! ** value
Run Code Online (Sandbox Code Playgroud) 嗨,我对编程非常陌生,但这是我遇到的错误。这是我的代码...
override fun onRestoreInstanceState(savedInstanceState: Bundle?) {
super.onRestoreInstanceState(savedInstanceState)
val savedString = savedInstanceState?.getString(TEXT_CONTENTS, "")
editText2?.text = savedString
}
Run Code Online (Sandbox Code Playgroud)
最后的savedString 表达式我收到错误“Required Editable! found String?”