Skip to content

Instantly share code, notes, and snippets.

@zah
Created November 12, 2013 23:55
Show Gist options
  • Save zah/7440962 to your computer and use it in GitHub Desktop.
Save zah/7440962 to your computer and use it in GitHub Desktop.
typedesc iterator
import typetraits
iterator foo(x: int, T: typedesc): int =
echo x, T.name
yield 10
for x in foo(10, int):
echo x
@zah
Copy link
Author

zah commented Nov 12, 2013

Another version that also works:

import typetraits

iterator foo(x: int, T: typedesc): int =
  echo x, " ", T.name
  yield 20

for x in 10.foo(int):
  echo x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment