Github user twilmes commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/475#discussion_r86026558
  
    --- Diff: 
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/UnfoldStep.java
 ---
    @@ -46,6 +47,8 @@ else if (s instanceof Iterable)
                 return ((Iterable) s).iterator();
             else if (s instanceof Map)
                 return ((Map) s).entrySet().iterator();
    +        else if (s.getClass().isArray())
    +            return new ArrayIterator((Object[])s);
    --- End diff --
    
    This cast will fail if the incoming array is an array of primitives.  I 
think you could do something like this which is short and to the point but 
creates an intermediate, albeit short-lived list.
    `return (Iterator<E>)Arrays.asList(s).iterator();`
    
    I was able to reproduce the issue when I nested a primitive array inside of 
a list.  Calling `unfold` twice looks a little silly but maybe someone would do 
this if they were dealing with nested collections.
    
    ```
    gremlin> __.inject([0, 1, 2, [3, 4] as int[]]).unfold().unfold()
    ==>0
    ==>1
    ==>2
    [I cannot be cast to [Ljava.lang.Object;
    Type ':help' or ':h' for help.
    Display stack trace? [yN]n
    gremlin> __.inject([0, 1, 2, [3, 4]]).unfold().unfold()
    ==>0
    ==>1
    ==>2
    ==>3
    ==>4
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to