[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Basic question: how to use Enumerable#each_slice

Liang He

10/13/2007 9:26:00 AM

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?
--
Posted via http://www.ruby-....

1 Answer

Robert Klemme

10/13/2007 10:34:00 AM

0

On 13.10.2007 11:25, Liang He wrote:
> 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