Search code examples
elm

How to convert number to String


Is there a function like number -> String in Elm which formats number to String? Not looking for specific Int or Float type but a general converting function for "typeclass" number.


Solution

  • No.


    Generally the number typeclass exists mostly so that mathematical operators work for both Int and Float. I would recommend not trying to program generically against number in your own code, but just pick the appropriate one (that's usually Float, unless you're counting).