Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants