Scala Char self() method with example
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