I want to use a type alias in a generic type. but here I got into trouble:
class OrderedMap( K , V)
enum Color : UInt8
BLACK
RED
end
private RED = Color::RED
private BLACK = Color::BLACK
class Node(K1,V1)
#......
end
alias PNode = Pointer(Node(K,V))
@root : PNode = PNode.null
......
end
this doesn’t work :
In lib\ordered_map.cr:38:30
38 | alias PNode = Pointer(Node(K,V))
^
Error: undefined constant K
I tried to translate it from c++
class OrderedMap
//struct Node ------ failed in crystal
using pnode = *node<K,V> //the equivalent annotation
this type appears very often, so I do need a shorter name for it,instead of writingPointer(Node(K,V))
everywhere. Is there a better or just practicable way in crystal?