返回顶部

收藏

Call each a number of times

更多
module Enumerable
  def each_n_times(n)
    each { |e| n.times { yield e } }
  end
end

%w{Hello Echo}.each_n_times(3) { |x| puts x }
# Hello
# Hello
# Hello
# Echo
# Echo
# Echo

标签:Ruby,集合

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2016-12-25 16:45:49The intersection is the set of values that appear in both by 好好学习啊
  2. 2015-12-19 11:02:24Custom class based range by JustForFly
  3. 2016-01-16 09:59:29Sort with block by 胡晋
  4. 2016-01-20 16:52:19Each loop by zetaliang
  5. 2016-08-28 10:10:01Create set with Set.new by LeoSun
  6. 2016-08-28 13:57:54inorder / preorder / postorder by 永明
  7. 2016-09-16 19:29:52Classify a set into three by 永明
  8. 2016-01-13 11:51:16Create Your queue by 永明
  9. 2016-01-25 10:05:50The union is the set of values that appear in either by digua
  10. 2016-08-28 10:28:28Is it in a set by 永明
  11. 2016-08-28 14:18:49search a tree by digua
相关聚客文章
  1. hellolucky 发表 2012-07-17 12:26:19 [ Ruby on Rails ] Dragonfly 檔案上傳運作原理
  2. 周亮 发表 2013-01-14 16:39:37 几个有意思的Ruby全局变量
  3. 博主 发表 2007-03-10 08:00:00 Ruby/Rails RSS
  4. Philip Howard 发表 2012-06-20 00:00:00 Remote Ruby with LIRC
  5. wujian_hit 发表 2013-05-07 01:00:55 Ruby::Fiddle::CStruct undefined method `[]'
  6. 博主 发表 2013-05-14 13:00:00 Ruby 2.0.0-p195 is released
  7. xiaoxiao 发表 2013-05-20 04:53:39 ruby json问题
  8. polyzz 发表 2013-06-01 03:25:02 [北京] 招聘ruby程序员
  9. shlallen 发表 2013-06-07 02:15:24 ruby代码实现JasperReports Server WebService REST API调用
  10. xiaoxiao 发表 2013-06-15 13:29:23 ruby js 文件能带汉字吗
  11. 小蝴蝶 发表 2013-06-22 11:05:56 Octopress Installation Log
  12. hellolucky 发表 2013-06-26 16:09:35 [ Ruby on Rails ] Rails4 學習心得整理 (上)

发表评论