Range (computer programming)

Uses your system voice; voice and rate in settings.

Snapshot

≈ 1 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

In computer science, the term range may refer to one of three things: # The possible values that may be stored in a variable. # The upper and lower bounds of an array. # An alternative to iterator.

In computer science, the term range may refer to one of three things: The possible values that may be stored in a variable. The upper and lower bounds of an array. An alternative to iterator. public record Range (T Start, T End) where T : IComparable; Example in Kotlin. data class Range >(val start: T, val end: T) Example in PHP. readonly class Range { public function __construct( public T $start, public T $end, ) {} } Example in Python. from dataclasses import dataclass @dataclass class Range[T]: start: T end: T Rust has a built-in range struct in the standard library in . C++ has a library as well since C++20. let heartwarming = "heartwarming!".to_string(); let warm = &heartwarming[5..9]; Zig also has the operator. // To iterate over consecutive integers, use the range syntax. var sum: usize = 0; for (0..5) |i| { sum += i; } As does C#, string[] items = ["one","two","three","four"]; string[] firstThreeItems = items[0..2]; F#, [1..4] // Outputs: [1; 2; 3; 4] Kotlin, for (i in 1..5) print(i) and Perl. for( 1..5) { print } Python and PHP does not have any range operator but they do have a function.

Text derived from https://en.wikipedia.org/w/index.php?oldid=1377539724 under CC BY-SA 4.0; modifications have been made.