0

In scala , how does one achieve converting type Int to Number?

var A : Int = 10

How do i convert A to number type? I want to plot a bar chart using scalafx, and NumberAxis accept number as the data. So , i will need to convert Int to Number. How do i achieve that? Thank you

Brian Ruchiadi
  • 331
  • 1
  • 13
  • 29
  • where does this `Number` comes from? Provide links or you won't get any help. – pedrofurla Jun 18 '17 at 18:28
  • A is an integer.. Which is the data that i want to display on the bar chart.. And in bar chart, if i am not mistaken, for NumberAxis, the type must be Number.. I am confused on how to change it to Number.. From what i read Number is in java.. @pedrofurla – Brian Ruchiadi Jun 18 '17 at 18:36
  • Never mind..... – pedrofurla Jun 18 '17 at 20:04
  • Have you taken a look at the [API](http://www.scalafx.org/api/2.2/index.html#scalafx.scene.chart.NumberAxis)? I see a method called `toRealValue` which takes in a `Double` and returns a `Number`. You can do `toRealValue(A.toDouble)` – Tanjin Jun 18 '17 at 20:39
  • There are implicit conversions from the Scala native numeric types to the boxed Java Number types (in `Predef`). So, in most cases you shouldn't need to do anything. Can you give an example of what you want to do that doesn't work? – Joe Pallas Jun 19 '17 at 05:01

0 Answers0