@haxall/haxall
    Preparing search index...

    Class Range

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

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:

      this < that   =>  <0
      this == that => 0
      this > that => >0

      This method may also be accessed via the < <= <=> >= and > shortcut operators. If not overridden the default implementation compares the toStr representations. Also see docLang.

      Examples:

      3.compare(8)  =>  -1
      8.compare(3) => 1
      8.compare(8) => 0
      3 <=> 8 => -1 // shortcut for 3.compare(8)

      Parameters

      Returns number

    • Return if this range contains the specified integer.

      Example:

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

      Parameters

      • i: number

      Returns boolean

    • Call the specified function for each integer in the range. Also see Int.times.

      Example:

      (1..3).each |i| { echo(i) }          =>  1, 2, 3
      (1..<3).each |i| { echo(i) } => 1, 2
      ('a'..'z').each |Int i| { echo(i) } => 'a', 'b', ... 'z'

      Parameters

      • c: (arg0: number) => void

      Returns void

    • Iterate every integer in the range until the function returns non-null. If function returns non-null, then break the iteration and return the resulting object. Return null if the function returns null for every integer in the range.

      Parameters

      • c: (arg0: number) => JsObj

      Returns JsObj

    • Return end index.

      Example:

      (1..3).end  =>  3
      

      Returns number

    • Return true if same start, end, and exclusive.

      Parameters

      Returns boolean

    • Is the end index exclusive.

      Example:

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

      Returns boolean

    • Get the first value of the range. If range contains no values then return null. Equivalent to toList.first.

      Returns number

    • Return start ^ end.

      Returns number

    • Is the end index inclusive.

      Example:

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

      Returns boolean

    • Return if this range contains no integer values. Equivalent to toList.isEmpty.

      Returns boolean

    • Return if this Obj is immutable and safe to share between threads:

      • an instance of a const class
      • the result of toImmutable on List, Map, or Buf
      • a Func object may or may not be immutable - see sys::Func.
      • other instances are assumed mutable and return false

      Returns boolean

    • Get the last value of the range. If range contains no values then return null. Equivalent to toList.last.

      Returns number

    • Create a new list which is the result of calling c for every integer in the range. The new list is typed based on the return type of c.

      Example:

      (10..15).map |i->Str| { i.toHex }  =>  Str[a, b, c, d, e, f]
      

      Parameters

      • c: (arg0: number) => JsObj

      Returns List<JsObj>

    • Get the maximum value of the range. If range contains no values then return null. Equivalent to toList.max.

      Returns number

    • Get the minimum value of the range. If range contains no values then return null. Equivalent to toList.min.

      Returns number

    • Create a new range by adding offset to this range's start and end values.

      Example:

      (3..5).offset(2)   =>  5..7
      (3..<5).offset(-2) => 1..<3

      Parameters

      • offset: number

      Returns Range

    • Return start index.

      Example:

      (1..3).start  =>  1
      

      Returns number

    • Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:

      • if type is const, return this
      • if already an immutable List, Map, Buf, or Func return this
      • if a List, then attempt to perform a deep clone by calling toImmutable on all items
      • if a Map, then attempt to perform a deep clone by calling toImmutable on all values (keys are already immutable)
      • some Funcs can be made immutable - see sys::Func
      • if a Buf create immutable copy, see sys::Buf
      • any other object throws NotImmutableErr

      Returns Readonly<this>

    • Convert this range into a list of Ints.

      Example:

      (2..4).toList   =>  [2,3,4]
      (2..<4).toList => [2,3]
      (10..8).toList => [10,9,8]

      Returns List<number>

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

      Returns string

    • Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:

      a->x        a.trap("x", null)
      a->x() a.trap("x", null)
      a->x = b a.trap("x", [b])
      a->x(b) a.trap("x", [b])
      a->x(b, c) a.trap("x", [b, c])

      The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.

      Parameters

      Returns JsObj

    • Get the Type instance which represents this object's class. Also seeType.of or Pod.of.

      Returns Type

    • This method called whenever an it-block is applied to an object. The default implementation calls the function with this, and then returns this.

      Parameters

      • f: (arg0: this) => void

      Returns this

    • Write x.toStr to standard output followed by newline. If x is null then print "null". If no argument is provided then print an empty line.

      Parameters

      Returns void

    • Parse from string format - inclusive is "start..end", or exclusive is "start..<end". If invalid format then throw ParseErr or return null based on checked flag.

      Parameters

      • s: string
      • Optionalchecked: boolean
      • ...args: unknown[]

      Returns Range

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

      Parameters

      • start: number
      • end: number
      • exclusive: boolean
      • ...args: unknown[]

      Returns Range

    • Convenience for make(start, end, true).

      Parameters

      • start: number
      • end: number
      • ...args: unknown[]

      Returns Range

    • Convenience for make(start, end, false).

      Parameters

      • start: number
      • end: number
      • ...args: unknown[]

      Returns Range