Range

Overview

Used to identify range in a sequence.

Use case

You can use Range class when you need to specify a part of some sequence, for example Binary class uses Range to to read part of the data:

var Bin := new Sugar.Binary(Sugar.String("Hello World").ToByteArray);
writeLn(new Sugar.String(Bin.Read(Sugar.Range.MakeRange(6, 5)))); //outputs "World"

Location

  • Reference: Sugar
  • Namespace: Sugar
  • Ancestry: ValueType | Range

Properties


Length

Gets or sets number of items in range.

 

property Length: Int32 read write;

 

Int32 Length { get; set; }

 

var Length: Int32 { get{} set{} }

 

Int32 Length { __get; __set; }

Location

Gets or sets starting index of range.

 

property Location: Int32 read write;

 

Int32 Location { get; set; }

 

var Location: Int32 { get{} set{} }

 

Int32 Location { __get; __set; }

Class Methods


MakeRange

Creates a new Range with specified parameters.

 

class method MakeRange(aLocation: Int32; aLength: Int32): Range

 

static Range MakeRange(Int32 aLocation, Int32 aLength)

 

static func MakeRange(_ aLocation: Int32, _ aLength: Int32) -> Range

 

static Range MakeRange(Int32 aLocation, Int32 aLength)

Parameters:

  • aLocation: Starting index of range.
  • aLength: Number of items in range.

See Also