Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Scala Int self() method with example

  • Last Updated : 23 Feb, 2021

The self() method is utilized to return the same value which has been specified.
 

Method Definition: (Value).selfReturn 
Type: It returns true the same value which has been specified.

Example 1: 

Scala




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

 

Example 2: 

Scala




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



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!