首页
文章
活动
博客
图书
招聘
Search
登录
注册
数组里面100个元素,每10个一组输出(ruby)
2010-08-07
刘俊
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°
/
6057 人阅读
/
0 条评论
发表评论
请
登录
后发表评论
刘俊
访客 94247
刘俊
的其他博文
更多
FFI::NotFoundError: Function '_get_errno' not found in [msvcrt.dll]
another busy day(learning english)
ruby随机取值不重复
清除IE的cookies的一些命令
关于新起一个进程处理弹窗口的另一种方式
ruby小记录:获取当前方法名,行数,文件名
watir-webdriver remote control报错 The path to the driver executabl...
watir-webdriver在win7启动IE9的错误
360面试测试开发的一道算法题
学历感言