Basic question: how to use Enumerable#each_slice

L

Liang He

This are examples from library documentation
(1..10).each_slice(3) {|a| p a}
(1..10).each_cons(3) {|a| p a}

but when I run them in fxri, got such errors:

undefined method `each_slice' for 1..10:Range

Do I need to require any module?
 
R

Robert Klemme

This are examples from library documentation
(1..10).each_slice(3) {|a| p a}
(1..10).each_cons(3) {|a| p a}

but when I run them in fxri, got such errors:

undefined method `each_slice' for 1..10:Range

Do I need to require any module?

Yes, enumerator.

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top