Skip to content

getfield with integer index argument #4806

Closed
@WestleyArgentum

Description

When I want to iterate over all the members of a type the first valid syntax that comes to mind is roughly:

members = names(thing)
for name in members
    ...
end

But this might be pretty inefficient (I only looked deep enough to see a call to collect, I'm assuming it's creating a new array each time).

Maybe this has been discussed before, but wouldn't it be nice if I could:

for (name, value) in thing  # <--- treat the type like a dictionary
    ...
end

and count on things in the background to not allocate an array?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions