You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by tkruse <gi...@git.apache.org> on 2016/07/01 07:30:34 UTC

[GitHub] groovy pull request #360: Changed the `Range`'s `step` to `Number` instead o...

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

    https://github.com/apache/groovy/pull/360#discussion_r69260216
  
    --- Diff: src/main/groovy/lang/ObjectRange.java ---
    @@ -488,37 +500,61 @@ public void remove() {
     
         @Override
         public List step(int step) {
    +        return step((Number) step);
    +    }
    +
    +    /**
    +     * {@inheritDoc}
    +     */
    +    @Override
    +    public List step(Number step) {
             final IteratorClosureAdapter adapter = new IteratorClosureAdapter(this);
             step(step, adapter);
             return adapter.asList();
         }
     
         /**
    -     * Increments by one
    +     * Increments by step size
          *
          * @param value the value to increment
    -     * @return the incremented value
    +     * @param step  the value to increment by
    +     * @return the incremented value or null, if there isn't any
          */
    -    private static Object increment(Object value) {
    +    protected static Comparable increment(Comparable value, Number step) {
             if (value instanceof Number) {
    -            return plus((Number) value, 1);
    -        } else {
    -            return InvokerHelper.invokeMethod(value, "next", null);
    +            return (Comparable) plus((Number) value, step);
    +        }
    +
    +        for (int i = 0; compareLessThan(i, step); i++) {
    --- End diff --
    
    By funny stapping I mean stepping through an enumeration or a range of characters by step 2.7. I believe the current added tests do not cover the changes to ObjectRange well.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---