Skip to content
This repository was archived by the owner on Jul 12, 2025. It is now read-only.

WIP: Add Enumerator class #801

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

WIP: Add Enumerator class #801

wants to merge 1 commit into from

Conversation

hachi8833
Copy link
Member

This is just for my interest regarding #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>

@@ -1367,3 +1374,7 @@ func generateJSONFromPair(key string, v Object, t *Thread) string {

return out.String()
}

func (h *HashObject) Enumerable() bool {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method HashObject.Enumerable should have comment or be unexported

return out
}

//// Retrieves an object in an array using Integer index; common to `[]` and `at()`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment on exported method EnumeratorObject.Len should be of the form "Len ..."

GoMapClass = "GoMap"
DecimalClass = "Decimal"
BlockClass = "Block"
ObjectClass = "Object"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported const ObjectClass should have comment (or a comment on this block) or be unexported

@@ -1817,3 +1823,7 @@ func (a *ArrayObject) unshift(objs []Object) *ArrayObject {
a.Elements = append(objs, a.Elements...)
return a
}

func (a *ArrayObject) Enumerable() bool {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ArrayObject.Enumerable should have comment or be unexported

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants