Détails
Comment ajouter un tableau à un autre tableau en Ruby et ne pas se retrouver avec un résultat multidimensionnel ?
somearray = ["some", "thing"]
anotherarray = ["another", "thing"]
somearray.push(anotherarray.flatten!)
Je m'attendais à ce que
["some","thing","another","thing"]
448
3
Vous pouvez simplement utiliser l'opérateur
+
!Vous pouvez lire tout ce qui concerne la classe des tableaux ici: http://ruby-doc.org/core/classes/Array.html
Essayez ceci, cela combinera vos tableaux en supprimant les doublons.
http://www.ruby-doc.org/core/classes/Array.html
Pour plus de documentation, consultez la rubrique "Set Union" ;
["some" ;, "thing" ;] + ["another" ; + "thing" ;]
.