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

Added example for iterating over simple array. #42

Closed
wants to merge 1 commit into from

Conversation

dzeban
Copy link

@dzeban dzeban commented Apr 13, 2015

It's not clear from documentation how to iterate over scalar arrays (not an array of objects, e.g. like in example). _WJEString, _WJEInt32 which are intended to be "handy" on iterating over multiple elements are actually confusing since last argument has type WJElement. After struggling for an hour I've come up with a solution where you invoke WJEGet and then pull the value via "." selector. This is what this pull request demonstrate.

Maybe it's not the way someone should do this, but then, please, correct me and we'll update the documentation accordingly because as I said it's really confusing.

P.S. I haven't seen a "Firefly" and it was hard for me to come up with an appropriate example, so I would be glad if you suggest a better one.

@penduin
Copy link
Member

penduin commented Apr 13, 2015

Nice! That's a good idea, I'll probably include this as-is and update the javascript side of the example to match.

@dzeban
Copy link
Author

dzeban commented Apr 13, 2015

Great! But still - am I right that using WJEGet and "." or empty selector is a supposed way to iterate over array of scalars?

@penduin
Copy link
Member

penduin commented Apr 13, 2015

I applied and fixed up your patch a bit. You were appending empty objects {} to the element and then replacing them with strings; the example now just appends strings.

And yes, WJEGet and then WJEString et al with an empty selector or "." (or, as I did it, NULL) returns the value for the current element.

Thanks again, and... I really really need to add more examples, don't I? :^)

@penduin penduin closed this Apr 13, 2015
@dzeban
Copy link
Author

dzeban commented Apr 13, 2015

Thanks, looks great! As for examples - it's never enough ;-)

@dzeban dzeban deleted the doc-array branch April 14, 2015 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants