Socordia
  • Intro
    • The Compiler
  • The Basics
    • Variables
      • Arrays
    • Conditional Flow
    • Loops
    • Functions
    • Data
      • Casting
      • Enumerations
      • Ranges/Aliases
      • Structs
      • Tuples
      • Unit of Measure Types
  • Mixins
  • Accessibility
  • Primitive Datatypes
  • Extended
    • Conditional
    • Inline IL
    • Operator Overloading
    • Unions
    • OOP
      • Classes
      • Interfaces
Powered by GitBook
On this page
  • Ranges
  • Type Aliases
  1. The Basics
  2. Data

Ranges/Aliases

Ranges

A range represents a range of numbers or in some contexts a range of types. A range has a lower and a upper bound.

let range = 1..200;

The sample above uses a range from 1 to 200 inclusive. That means an array will be instantiated with all the values from 1 to 200.

Type Aliases

You can use a type by a custom name. This is called a type alias. (Currently type aliases are bound to the whole assembly/program)

The definition:

<type_alias> ::= "using" <identifier> "as" <identifier> ";"

Example:

using int as i32;

func main() -> int {
  return 42;
}

As you can see in the sample above the alias type can be used as if it were a normal integer.

PreviousEnumerationsNextStructs

Last updated 5 months ago