Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

HandsOn Scala

object PatternMatching1
{
    
   
    
    
   def main(args: Array[String])
   {
      def matchText(x : Any) : Any = x match   
      {
          
          
          case 1 => "  One  "
          case "two" => 2
          case y: Int => " You have entered an integer >2   "
          case _ => "many"
          
          
           println(matchText(3)) 
           println(matchText(2))
           println(matchText("two")) 
           println(matchText(" Oops" )) 
    
          
      }   
       
       
   }
  
  
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.