Skip to content

Commit 75b18a4

Browse files
Merge pull request #85 from FrogBomb/patch-1
Clarify introduction to "Ranges"
2 parents 0fa6295 + 915ce7a commit 75b18a4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/scala/stdlib/Ranges.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import org.scalatest._
1212
*/
1313
object Ranges extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {
1414

15-
/** 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)`.
15+
/** 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".
1616
*
17-
* 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)`.
17+
* 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".
18+
*
19+
* Note that `Range(a, b, c)` is the same as `a until b by c`
1820
*
1921
* 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.
2022
*

0 commit comments

Comments
 (0)