Ranges

Last updated

What is Ranges?

Ranges in Ruby are used to create a sequence of values. They are defined using two endpoints, which can be numbers, characters, or any objects that can be compared using the <=> operator. Ranges can be inclusive (including the last value) or exclusive (excluding the last value), denoted by .. and ... respectively. They are commonly used for iterating over a sequence, creating subsets of arrays, and checking if a value falls within a specific interval.

Free resources to learn Ranges

More in stage 9: Operators

Ranges: common questions

Can I learn Ranges in Hindi?

This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Ranges in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.

Is this Ranges tutorial for beginners?

It is lesson 25 of 102 in the free Ruby roadmap, in stage 9, Operators. If you are new to Ruby, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.

Still confused? Ask me