Mojo slice __init__() Function

The Mojo slice __init__() function “constructs a slice given the end value”.

Syntax 1

__init__(end: Int) -> Self

Return value

It returns the constructed slice.

Syntax 2

__init__(start: Int, end: Int) -> Self

Parameters

  1. start (Int): The start value.
  2. end (Int): The end value.

Return value

It constructs the slice given the start and end values.

Syntax 3

It constructs the slice given the start, end, and step values.

__init__[T0: AnyType, T1: AnyType, T2: AnyType](start: T0, end: T1, step: T2) -> Self

Parameters

  1. T0 (AnyType): Type of the start value.
  2. T1 (AnyType): Type of the end value.
  3. T2 (AnyType): Type of the step value.

Return value

It returns the constructed slice.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.