mardi 19 novembre 2019

Scala matching arrays 2d

I have 2d Array which is declared like that init_ : Array[Array[Int]]

In this 2d array, i can only have "1","2" or "3". I'm looking to print something different when i iterate on these elements, something like that :

  override def toString = {  
    val c = init.map(_.clone);  

    c match{
      case 1 => ret = "one"
      case 2 => ret = "two"
      case 3 => ret = "three"
    }
    ret
  }

I'm beginning in Scala so please, be indulgent

Thanks

Aucun commentaire:

Enregistrer un commentaire