返回顶部

收藏

Generator based on regualr expression

更多
require 'generator'
l = ['junk1', 1, 'junk2', 2, 'junk3', 'junk4', 3, 'junk5']

g = Generator.new { |g| l.each { |e| g.yield e unless e =~ /^junk/ } }
g.next                                            # => 1
g.next                                            # => 2
g.next                                            # => 3

标签:Ruby,基础

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2012-11-05 21:59:42java获得随机数代码 by 怪兽狂殴奥特曼
  2. 2016-01-03 10:10:13Working with Ruby Interactively, start irb by Loli控
  3. 2016-01-05 19:26:29Field and precision combined by 胡晋
  4. 2016-01-12 21:33:50print Statement by 好好学习啊
  5. 2016-02-02 11:29:56Processing Files with RDoc by Ω油菜
  6. 2016-03-03 11:24:01Using a Shebang Line on Unix/Linux by LeoSun
  7. 2016-03-20 09:22:36What are Comments by JustForFly
  8. 2016-03-24 09:14:45Abstract method in a module by digua
  9. 2016-04-25 20:26:14Mixing in Class Methods.rb by Ω油菜
  10. 2016-09-05 14:26:54Are more than two statements OK? by Ω油菜
  11. 2016-09-05 17:50:31Creating Mixins by digua

发表评论