goby-lang / goby

Goby - Yet another programming language written in Go
MIT License
3.49k stars 171 forks source link

WIP: Add Enumerator class #801

Open hachi8833 opened 4 years ago

hachi8833 commented 4 years ago

This is just for my interest regarding https://github.com/goby-lang/goby/issues/342 .

This apparently works but is still not the real Enumerator class. Currently, only Array#to_enum, Hash#to_enum, Enumerator#inspect is available. (:each is a fake😆)

» a = [1, 2, 3].to_enum
#» <Enumerator: [1, 2, 3]:each>
» a.class
#» Enumerator
» a.inspect
#» <Enumerator: [1, 2, 3]:each>

» h = {k1: 1, k2:2}.to_enum
#» <Enumerator: { k1: 1, k2: 2 }:each>
» h.class
#» Enumerator
» h.inspect
#» <Enumerator: { k1: 1, k2: 2 }:each>