Skip to content

Commit

Permalink
feat: make Int a subclass of Float
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Nov 2, 2024
1 parent 0bb1df0 commit f95ecaf
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,49 +61,49 @@ class Boolean
class Number

/**
* An integer.
* A floating-point number.
*
* @example
* pipeline example {
* val int = 1;
* val float = 1.0;
* }
*/
class Int sub Number {
class Float sub Number {

/**
* Convert this integer to a floating-point number.
* Convert this floating-point number to an integer by truncating the fractional part.
*
* @example
* pipeline example {
* val float = 1.toFloat(); // 1.0
* val int = (1.0).toInt(); // 1
* }
*/
@Pure
@PythonMacro("float($this)")
fun toFloat() -> float: Float
@PythonMacro("int($this)")
fun toInt() -> int: Int
}

/**
* A floating-point number.
* An integer.
*
* @example
* pipeline example {
* val float = 1.0;
* val int = 1;
* }
*/
class Float sub Number {
class Int sub Float {

/**
* Convert this floating-point number to an integer by truncating the fractional part.
* Convert this integer to a floating-point number.
*
* @example
* pipeline example {
* val int = 1.0.toInt(); // 1
* val float = 1.toFloat(); // 1.0
* }
*/
@Pure
@PythonMacro("int($this)")
fun toInt() -> int: Int
@PythonMacro("float($this)")
fun toFloat() -> float: Float
}

/**
Expand Down

0 comments on commit f95ecaf

Please sign in to comment.