I have code in Scala:
def method1 (obj: AnyRef) = { (Obj.isInstanceOf [Aure [boolean]]) {return arrays.toString (obj.asInstanceOf [Aure [boolean]] if (obj == faucet) return to "null" (obj.isInstanceOf [Array [char] ]] {Return Arrays.toString (obj.asInstanceOf [Array [char]]}} if (obj.isInstanceOf [array [byte]]) {return arrays.toString (obj.asInstanceOf [array [byte]]) if (if Obj.isInstanceOf [aae [long]] {return arrays.toString (obj.asInstanceOf [array [long]] // and so on .... I was thinking About implementing match here, but not me I know how I will do this. Is there any way to make it more efficient in both simplicity and performance?
Simplicity?
sc: Def (a: Any) = one match {| case_: array [int] =>" Ints "| | _: Array [double] = & gt; "dubs" |} F: (a: any) string scale & gt; F (array (1,2,3)) res2: string = ITS scale & gt; F (array (1.1,2.2,3.3)) res3: string = dubs I think you mean:
def f (a: Any) = a match {case x: array [int] = & gt; Arrays.toString (x) Case x: array [double] = & gt; Arrays.toString (x)}
No comments:
Post a Comment