我目前工作的一个大阵的名称上:配售子阵列
large_array = ["Bob","Joel","John","Smith","Kevin","Will","Stanley","George"] #and so on
我把它分解成子阵列,像这样:
large_array.each_slice(2).to_a #=> [["Bob", "Joel"],["John,"Smith"],["Kevin", "Will"],["Stanley","George"]]
我的问题是我怎么做在子阵列上彼此的顶部上以行整齐地出现这样的:
["Bob", "Joel"]
["John,"Smith"]
["Kevin","Will"]
["Stanley","George"]
要打印它'stdout'或在任何文件? –
我试图让它看起来像这样在irb – user1762229
试试这个http://stackoverflow.com/questions/2112016/formatting-rubys-prettyprint –