logo

const final class

sys::Range

sys::Obj
  sys::Range

Range represents a contiguous range of integers from start to end. Ranges may be represented as literals in Fan source code as "start..end" for an inclusive end or "start...end" for an exlusive range.

Slots

contains

Bool contains(Int i)

Return if this range contains the specified integer.

Example:

(1..3).contains(2)  =>  true
(1..3).contains(4)  =>  false

Source

each

Void each(|Int| c)

Call the specified function for each integer in the range.

Example:

('a'..'z').each |Int i| { echo(i) }

Source

end

Int end()

Return end index.

Example:

(1..3).end  =>  3

Source

equals

override Bool equals(Obj obj)

Return true if same start, end, and exclusive.

Source

exclusive

Bool exclusive()

Is the end index exclusive.

Example:

(1..3).exclusive   =>  false
(1...3).exclusive  =>  true

Source

hash

override Int hash()

Return start ^ end.

Source

inclusive

Bool inclusive()

Is the end index inclusive.

Example:

(1..3).inclusive   =>  true
(1...3).inclusive  =>  false

Source

make

new make(Int start, Int end, Bool exclusive)

Constructor with start, end, and exclusive flag (all must be non-null).

Source

makeExclusive

new makeExclusive(Int start, Int end)

Convenience for make(start, end, true).

Source

makeInclusive

new makeInclusive(Int start, Int end)

Convenience for make(start, end, false).

Source

start

Int start()

Return start index.

Example:

(1..3).start  =>  1

Source

toStr

override Str toStr()

If inclusive return "start..end", if exclusive return "start...end".

Source