Conversation
100d9e3 to
97a7fa1
Compare
97a7fa1 to
63921c6
Compare
|
|
||
| # `Range` requires `begin <=> end` to return non-nil, but doesn't actually | ||
| # end up using the return value of it. This is to add that in when needed. | ||
| def lower.<=>(rhs) = :not_nil unless defined? lower.<=> |
There was a problem hiding this comment.
The former varient was technically incorrect; the new one now properly defines the singleton funtion only if lower.<=> doesnt exist
| class Numeric | ||
| include Comparable | ||
|
|
||
| type round_half = string | :up | :down | :even | 'up' | 'down' | 'even' |
There was a problem hiding this comment.
Used in the round functions in Numeric, Integer, and Float. The string at the start allows for _ToStrs
| end | ||
|
|
||
| # Returns whether `self` is less than `Other`. | ||
| interface _OpLt[Other] |
There was a problem hiding this comment.
Technically, these traits can return anything (like _OpAdd and friends), but the stdlib only returns booleans, so I've made them return bool. We theoretically could do boolish if that's desired, but i'm not a big fan of it
| # Performs integer division of `self` by `Other`. | ||
| interface _Div[Other] | ||
| # Performs the integer division. | ||
| def div: (Other other) -> Integer |
There was a problem hiding this comment.
Just like the _OpLt and friends, this one and _DivMod also technically return anything, but keeping them inline with ruby standard definitions seems ideal.
| end | ||
|
|
||
| module WithStdlibAliases | ||
| def with_round_half(&block) |
There was a problem hiding this comment.
These new methods will eventually also be used in Numeric, Float, etc.
| # | ||
| def nobits?: (int mask) -> bool | ||
|
|
||
| def nonzero?: () -> self? |
There was a problem hiding this comment.
Oddly enough, nonzero? isn't defined on integers, but zero? is
| | (2) -> String | ||
| | (3) -> String | ||
| | (4) -> String | ||
| | (5) -> String | ||
| | (6) -> String | ||
| | (7) -> String | ||
| | (8) -> String | ||
| | (9) -> String | ||
| | (10) -> String | ||
| | (11) -> String | ||
| | (12) -> String | ||
| | (13) -> String | ||
| | (14) -> String | ||
| | (15) -> String | ||
| | (16) -> String | ||
| | (17) -> String | ||
| | (18) -> String | ||
| | (19) -> String | ||
| | (20) -> String | ||
| | (21) -> String | ||
| | (22) -> String | ||
| | (23) -> String | ||
| | (24) -> String | ||
| | (25) -> String | ||
| | (26) -> String | ||
| | (27) -> String | ||
| | (28) -> String | ||
| | (29) -> String | ||
| | (30) -> String | ||
| | (31) -> String | ||
| | (32) -> String | ||
| | (33) -> String | ||
| | (34) -> String | ||
| | (35) -> String | ||
| | (36) -> String |
There was a problem hiding this comment.
Like @ParadoxV5 said, presumably these cases were for documentation about which int literals can be given, but they're covered under int, as well arent even TypeErrors
| def +@: () -> Integer | ||
|
|
||
| %a{steep:deprecated} | ||
| def abs2: () -> Integer | ||
|
|
||
| %a{steep:deprecated} | ||
| def angle: () -> (Integer | Float) | ||
|
|
||
| %a{steep:deprecated} | ||
| alias arg angle | ||
|
|
||
| %a{steep:deprecated} | ||
| def conj: () -> Integer | ||
|
|
||
| %a{steep:deprecated} | ||
| def conjugate: () -> Integer | ||
|
|
||
| %a{steep:deprecated} | ||
| def dup: () -> self | ||
|
|
||
| %a{steep:deprecated} | ||
| def eql?: (untyped) -> bool | ||
|
|
||
| %a{steep:deprecated} | ||
| def finite?: () -> bool | ||
|
|
||
| %a{steep:deprecated} | ||
| def i: () -> Complex | ||
|
|
||
| %a{steep:deprecated} | ||
| def imag: () -> Integer | ||
|
|
||
| %a{steep:deprecated} | ||
| def imaginary: () -> Integer | ||
|
|
||
| %a{steep:deprecated} | ||
| def infinite?: () -> Integer? | ||
|
|
||
| %a{steep:deprecated} | ||
| def negative?: () -> bool | ||
|
|
||
| %a{steep:deprecated} | ||
| def nonzero?: () -> self? | ||
|
|
||
| %a{steep:deprecated} | ||
| alias phase angle | ||
|
|
||
| %a{steep:deprecated} | ||
| def polar: () -> [ Integer, Integer | Float ] | ||
|
|
||
| %a{steep:deprecated} | ||
| def positive?: () -> bool | ||
|
|
||
| %a{steep:deprecated} | ||
| def quo: (Integer) -> Rational | ||
| | (Float) -> Float | ||
| | (Rational) -> Rational | ||
| | (Complex) -> Complex | ||
| | (Numeric) -> Numeric | ||
|
|
||
| %a{steep:deprecated} | ||
| def real: () -> self | ||
|
|
||
| %a{steep:deprecated} | ||
| def real?: () -> true | ||
|
|
||
| %a{steep:deprecated} | ||
| def rect: () -> [ Integer, Numeric ] | ||
|
|
||
| %a{steep:deprecated} | ||
| alias rectangular rect | ||
|
|
||
| %a{steep:deprecated} | ||
| def step: () { (Integer) -> void } -> void | ||
| | (Numeric limit, ?Integer step) { (Integer) -> void } -> void | ||
| | (Numeric limit, ?Numeric step) { (Numeric) -> void } -> void | ||
| | (to: Numeric, ?by: Integer) { (Integer) -> void } -> void | ||
| | (by: Numeric, ?to: Numeric) { (Numeric) -> void } -> void | ||
| | () -> Enumerator[Integer, bot] | ||
| | (Numeric limit, ?Integer step) -> Enumerator[Integer, void] | ||
| | (Numeric limit, ?Numeric step) -> Enumerator[Numeric, void] | ||
| | (to: Numeric, ?by: Integer) -> Enumerator[Integer, void] | ||
| | (by: Numeric, ?to: Numeric) -> Enumerator[Numeric, void] | ||
|
|
||
| %a{steep:deprecated} | ||
| def to_c: () -> Complex |
There was a problem hiding this comment.
None of these are defined on Integer, but instead on Numeric
| 3.angle() | ||
| testing "::Integer" | ||
|
|
||
| def with_random_Integers |
There was a problem hiding this comment.
Instead of using hardcoded integers, I figured generally using a range of integers would cover more cases.
This PR updates
Integer's signature.