-1

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? enter image description here

kxaio1117
  • 11
  • 2
  • 1
    Please share any relevant code by editing your Question - [instead of a screenshot](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question). Fewer people are likely to reproduce your issue without having your code in a copyable form. – tjheslin1 Nov 27 '21 at 08:38

1 Answers1

2

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
jwvh
  • 50,871
  • 7
  • 38
  • 64