0 votes
in Ruby by
Explain Ruby ranges. What are the ways to define ranges?

1 Answer

0 votes
by

Ruby range represents a set of values with a beginning and an end. They can be constructed using s..e and s...e literals or with ::new.

The ranges which has .. in them, run from beginning to end inclusively. The ranges which has ... in them, run exclusively the end value.

Ruby has a variety of ways to define ranges.

  • Ranges as sequences
  • Ranges as conditions
  • Ranges as intervals
...