Overview | Package | Class | Deprecated | Index | Help
| Groovy 1.7.0
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD

## groovy.lang
Interface Range

    java.lang.Iterable
      groovy.lang.Range
          java.util.Collection

    interface Range
    extends List

A Range represents the list of all items obtained by starting from a `from` value and calling `next()` successively until you reach the `to` value. For a reverse range, the list is obtained by starting at the `to` value and successively calling `previous()` until the `from` value is reached.

author:
  James Strachan

version:
  $Revision: 18210 $

Method Summary
`boolean` | `containsWithinBounds(Object o)` Indicates whether an object is greater than or equal to the `from` value for the range and less than or equal to the `to` value.
`Comparable` | `getFrom()` The lower value in the range.
`Comparable` | `getTo()` The upper value in the range.
`String` | `inspect()` to create the {
`boolean` | `isReverse()` Indicates whether this is a reverse range which iterates backwards starting from the to value and ending on the from value
`void` | `step(int step, Closure closure)` Steps through the range, calling a closure for each number.
`List` | `step(int step)` Forms a list by stepping through the range by the indicated interval.

Methods inherited from interface List
add, add, get, hashCode, indexOf, clear, equals, contains, isEmpty, lastIndexOf, addAll, addAll, iterator, size, toArray, toArray, remove, remove, set, containsAll, listIterator, listIterator, removeAll, retainAll, subList

Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll

Method Detail

### containsWithinBounds

    public boolean containsWithinBounds(Object o)

  Indicates whether an object is greater than or equal to the `from` value for the range and less than or equal to the `to` value.
  param:
    o the object to check against the boundaries of the range
  return:
    `true` if the object is between the from and to values

### getFrom

    public Comparable getFrom()

  The lower value in the range.
  return:
    the lower value in the range.

### getTo

    public Comparable getTo()

  The upper value in the range.
  return:
    the upper value in the range

### inspect

    public String inspect()

  return:
    the verbose String representation of this Range as would be typed into a console to create the Range instance

### isReverse

    public boolean isReverse()

  Indicates whether this is a reverse range which iterates backwards starting from the to value and ending on the from value
  return:
    `true` if this is a reverse range

### step

    public void step(int step, Closure closure)

  Steps through the range, calling a closure for each number.
  param:
    step the amount by which to step. If negative, steps through the range backwards.
  param:
    closure the Closure to call

### step

    public List step(int step)

  Forms a list by stepping through the range by the indicated interval.
  param:
    step the amount by which to step. If negative, steps through the range backwards.
  return:
    the list formed by stepping through the range by the indicated interval.

Copyright © 2003-2009 The Codehaus. All rights reserved.