RSSAmplifier

Max Chernyak · Aug 7, 2022

Ruby Enumerator.new(size)

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

Every ruby enumerator supports count . It’s a method that will iterate over every item and return their total count. irb> enum = Enumerator.new { |yielder| ( 1 .. 100 ).each do |i| puts "counting item: #{i} " yielder << i end } irb> enum.count counting item: 1 counting item: 2 … counting item: 100 => 100 However, Enumerable also has size . Except, by default it’s just nil . irb> enum.size => nil A…

Read on max.engineer

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.