mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-05 03:14:08 +00:00
set[T].len is an alias for set[T].card (#11885) [feature]
This commit is contained in:
committed by
Andreas Rumpf
parent
61c66abbfe
commit
d208d7a995
@@ -1111,6 +1111,9 @@ proc card*[T](x: set[T]): int {.magic: "Card", noSideEffect.}
|
||||
## var a = {1, 3, 5, 7}
|
||||
## echo card(a) # => 4
|
||||
|
||||
proc len*[T](x: set[T]): int {.magic: "Card", noSideEffect.}
|
||||
## An alias for `card(x)`.
|
||||
|
||||
proc ord*[T: Ordinal|enum](x: T): int {.magic: "Ord", noSideEffect.}
|
||||
## Returns the internal `int` value of an ordinal value ``x``.
|
||||
##
|
||||
|
||||
@@ -207,6 +207,10 @@ echo warnUninit in gNotes
|
||||
doAssert {-1.int8, -2, -2}.card == 2
|
||||
doAssert {1, 2, 2, 3..5, 4..6}.card == 6
|
||||
|
||||
# merely test the alias
|
||||
doAssert {-1.int8, -2, -2}.len == 2
|
||||
doAssert {1, 2, 2, 3..5, 4..6}.len == 6
|
||||
|
||||
type Foo = enum
|
||||
Foo1 = 0
|
||||
Foo2 = 1
|
||||
|
||||
Reference in New Issue
Block a user