I am a new learner of scala and I am coding a simple scalafx calculator and now I face a problem. I cannot find another suitable code to replace the parseDouble. I know the parseDouble is the member of java double, not scala double. I just put the code here to express my thoughts. Can someone help me to fix the code?
CodePudding user response:
You can invoke the Java parser directly...
val n1 = java.lang.Double.parseDouble(display.getText())
...or you can use the Scala .toDouble
.
val n1 = display.getText().toDouble
CodePudding user response:
In this case, I first thought of using switch, although it is just as long.