How to arrange return order in an idiomatic way using pattern matching in Scala -


  def arrange(str1: string, str2: string): (string, string) = {     if (str1 == "yellow") {       return (str1, str2)     } else {       return (str2, str1)     }   } 

i imagine write using pattern matching in more idiomatic way

   def arrange(str1: string, str2: string) = str1 match {      case "yellow" => str1 -> str2      case _ => str2 -> str1    } 

Comments

Popular posts from this blog

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - SSE Emitter : Manage timeouts and complete() -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -