How To Get Absolute Value In Scala

[Solved] How To Get Absolute Value In Scala | Scala - Code Explorer | yomemimo.com
Question : how to get absolute value in scala

Answered by : zac

// Scala program of Int abs()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying abs method
        val result = (-5).abs
          
        // Displays output
        println(result)
      
    }
}

Source : https://www.geeksforgeeks.org/scala-int-abs-method-with-example/ | Last Update : Sat, 05 Mar 22

Answers related to how to get absolute value in scala

Code Explorer Popular Question For Scala