Ranges - Spicery/Nutmeg GitHub Wiki

Closed Ranges

Closed ranges are written A ... B, where A and B expressions, and return a ListLike object that include the ordered values between A and B inclusively. They can be used on numbers and characters. e.g.

  • 1 ... 5 includes the values 1, 2, 3, 4 and 5.
  • `a` ... `z` includes the lower-case letters between a and z.

Half-Open Ranges

Half-open ranges are very similar to closed-ranges except that they exclude the final value. For example:

  • 1 ..< 5 includes the values 1, 2, 3 and 4.
  • `0` ..< `9` includes the digits 0 through to 8.

Additional Remarks

  • The range operators '...' and '..<' are borrowed from the Swift programming language.