Open In App

Scala Char asDigit() method with example

Last Updated : 03 Nov, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The asDigit() method is utilized to represent characters in the form of digit.

Method Definition: def asDigit: Int

Return Type: It returns Int.

Example: 1#




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


Output:

10

Example: 2#




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


Output:

14


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads