From 915ce7aefe7173fb3b5f119dbb316fb6d2ca90c3 Mon Sep 17 00:00:00 2001 From: Tom Blanchet Date: Wed, 12 Apr 2017 22:23:42 -0600 Subject: [PATCH] Clarify introduction to "Ranges" Changed some of the language and syntax used in the introduction of the "Ranges" section for more accuracy and clarity. --- src/main/scala/stdlib/Ranges.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/scala/stdlib/Ranges.scala b/src/main/scala/stdlib/Ranges.scala index b4a4b915..64a5f81c 100644 --- a/src/main/scala/stdlib/Ranges.scala +++ b/src/main/scala/stdlib/Ranges.scala @@ -12,9 +12,11 @@ import org.scalatest._ */ object Ranges extends FlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** A Range is an ordered sequence of integers that are equally spaced apart. For example, "1, 2, 3" is a range, as is "5, 8, 11, 14". To create a range in Scala, use the predefined methods `to` and `by`. `1 to 3` generates `Range(1, 2, 3)` and `5 to 14 by 3` generates `Range(5, 8, 11, 14)`. + /** A Range is an ordered sequence of integers that are equally spaced apart. For example, "1, 2, 3" is a range, as is "5, 8, 11, 14". To create a range in Scala, use the predefined methods `to`, `until`, and `by`. `1 to 3` generates "1, 2, 3" and `5 to 14 by 3` generates "5, 8, 11, 14". * - * If you want to create a range that is exclusive of its upper limit, then use the convenience method `until` instead of `to`: `1 until 3` generates `Range(1, 2)`. + * If you want to create a range that is exclusive of its upper limit, then use `until` instead of `to`: `1 until 3` generates "1, 2". + * + * Note that `Range(a, b, c)` is the same as `a until b by c` * * Ranges are represented in constant space, because they can be defined by just three numbers: their start, their end, and the stepping value. Because of this representation, most operations on ranges are extremely fast. *