首页
文章
活动
博客
图书
招聘
Search
登录
注册
数组里面100个元素,每10个一组输出(ruby)
2012-12-11
刘俊
a = []
1.upto(100) {|i| a << i}
class Array
def group n
arr = []
0.step(self.size, n) do |i|
arr << self[i, n]
end
arr
end
end
a.group(10).each {|g| puts g.join('-')}
2
该文章对我有帮助
605°
/
6054 人阅读
/
0 条评论
发表评论
请
登录
后发表评论
刘俊
访客 94244
刘俊
的其他博文
更多
关闭:为帮助保护你的安全,Internet Explorer已经阻止了从此站点下载文件到你的计算机
ruby保留的系统变量
测试部门的美女
another busy day(learning english)
document的一些方法(转)
minitest框架用断言提示no such file to load -- diff.exe
watir-webdriver在win7启动IE9的错误
安装gem的时候提示“make”不是内部或外部命令
奇虎360招聘,麻烦博主帮忙转发一下
与技术无关