Ruby Group Parts of An Array

来源:互联网 发布:mysql安装包下载 64位 编辑:程序博客网 时间:2024/04/28 15:03

I start out with a following simple array, as such:

a = ["a", "b", "c", "d", "e", "f"]

I want the below. How do I get this?

a = ["ab", "cd", "ef"]
try:
 a.each_slice(2).map(&:join)
 a.join.scan /../
0 0
原创粉丝点击