Open In App

Scala Char unary_~() method with example

Last Updated : 29 Oct, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The unary_~() method is utilized to find the bit-wise negation value of the stated character.

Method Definition: def unary_~: Int

Return Type: It returns bit-wise negative value of the stated character.

Example: 1#




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


Output:

-66

Example: 2#




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


Output:

-67


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads