Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



#extractor-objects #scala

// The injection method (optional)
def apply(user: String, domain: String) = { user +"@"+ domain }

// The extraction method (mandatory)
def unapply(str: String): Option[(String, String)] = {
  val parts = str split "@"
  if (parts.length == 2) { Some(parts(0), parts(1)) }
  else{ None }
}

If you want to change selection, open document below and click on "Move attachment"

Scala Extractors
ly method : " + apply("Zara", "gmail.com")); println ("Unapply method : " + unapply("Zara@gmail.com")); println ("Unapply method : " + unapply("Zara Ali")); } <span>// The injection method (optional) def apply(user: String, domain: String) = { user +"@"+ domain } // The extraction method (mandatory) def unapply(str: String): Option[(String, String)] = { val parts = str split "@" if (parts.length == 2){ Some(parts(0), parts(1)) }else{ None } } } This object defines both apply and unapply methods. The apply method has the same meaning as always: it turns Test into an object that can be applied to arguments in parentheses in th


Summary

statusnot read reprioritisations
last reprioritisation on suggested re-reading day
started reading on finished reading on

Details



Discussion

Do you want to join discussion? Click here to log in or create user.