logo
  • 教程列表
  • SO官方文檔
  • 普查員
    • 自定義列舉器
    • 現有方法
    • 復卷
  1. StackOverflow 文件
  2. Ruby Language 教程
  3. 普查員
  4. 復卷

復卷

Created: November-22, 2018

使用 rewind 重新啟動列舉器。

ℕ = Enumerator.new do |yielder|
  x = 0
  loop do
    yielder << x
    x += 1
  end
end

ℕ.next
# => 0

ℕ.next
# => 1

ℕ.next
# => 2

ℕ.rewind

ℕ.next
# => 0
  • 現有方法

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明