It was probably made before SomeInteger existed some of the code there is very
old
This is something I don't understand : The implementation of SomeOrdinal in
/lib/system/basic_types.nim, on line 32 is the following:
SomeOrdinal* =
int|int8|int16|int32|int64|bool|enum|uint|uint8|uint16|uint32|uint64
Run
Isn't it better (shorter) to write : `SomeOrdi
I did few tests to understand better generics syntax. This is a cool
observation I made (Just for beginners like me who don't know it): If I write :
func myfunc[T1, T2: uint8| int8](number1: T1, number2: T2): bool =
Run
T1 is concerned by the constrain (uint8 | int8).
Gracias very much ;-).
Use `SomeInteger`, `SomeFloat` or `SomeNumber`
This way:
func myfunc(number: SomeInteger) =
Run
https://nim-lang.github.io/Nim/system.html#SomeInteger
There is the `SomeNumber` which is `SomeFloat | SomeInt` which.. goes all the
way up. From docs [here](https://nim-lang.org/docs/system.html#SomeNumber)
Hello world. Here's the first line of my function:
func myfunc[T: int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 |
uint32 | uin64 ](number: T) =
Run
It could be longer, for example if I add floating types. Is there any way to
shorten that code ?