mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 14:55:24 +00:00
fix #5968
This commit is contained in:
committed by
Andreas Rumpf
parent
24966e006a
commit
b199c5af4e
20
tests/concepts/t5968.nim
Normal file
20
tests/concepts/t5968.nim
Normal file
@@ -0,0 +1,20 @@
|
||||
discard """
|
||||
exitcode: 0
|
||||
"""
|
||||
|
||||
type
|
||||
Enumerable[T] = concept e
|
||||
for it in e:
|
||||
it is T
|
||||
|
||||
proc cmap[T, G](e: Enumerable[T], fn: proc(t: T): G): seq[G] =
|
||||
result = @[]
|
||||
for it in e: result.add(fn(it))
|
||||
|
||||
import json
|
||||
|
||||
var x = %["hello", "world"]
|
||||
|
||||
var z = x.cmap(proc(it: JsonNode): string = it.getStr & "!")
|
||||
assert z == @["hello!", "world!"]
|
||||
|
||||
Reference in New Issue
Block a user