'is' operator for generic code
This commit is contained in:
parent
6a8a409f1b
commit
05cffb9370
4 changed files with 25 additions and 22 deletions
13
tests/accept/run/tisopr.nim
Normal file
13
tests/accept/run/tisopr.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
discard """
|
||||
output: "true true false yes"
|
||||
"""
|
||||
|
||||
proc IsVoid[T](): string =
|
||||
when T is void:
|
||||
result = "yes"
|
||||
else:
|
||||
result = "no"
|
||||
|
||||
const x = int is int
|
||||
echo x, " ", float is float, " ", float is string, " ", IsVoid[void]()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue