Open In App

Scala Char self() method with example

Improve
Improve
Like Article
Like
Save
Share
Report

The self() method is utilized to return the stated character itself.

Method Definition: def self: Char

Return Type: It returns Char.

Example: 1#




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


Output:

F

Example: 2#




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


Output:

9


Last Updated : 03 Nov, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads