Hi,
I'm taking a look into concept[T]. I hope you don't mind, I'll probably ask for
some help on this forum from time to time.
Could you please take a very careful look at the following code? This is not
working (right now), but should it work with this syntax?
# Container must have a "get" function
type Container[T] = concept c
get(c, int) is T
# We create this "get" function for seq[T],
# therefore seq[int] is a Container
proc get[T](c: seq[T], i: int): T = c[i]
# Any container can have the first element:
proc first[T](x: Container[T]): T = get(x, 0)
# Use "first" on a seq[int]
echo first(@[10,11,12])
By the way, is `myVar is myType` equivalent to `type(myVar) == myType`? If yes,
then is `type(value) is T` in the manual's "Concepts" section a typo?
Thanks,
Peter