Re: [noob] enums and index

2017-07-12 Thread LeuGim
If you'll add a type cast in inddexing, your snippet will work (either of them): echo capital[ITALY.int] And Byou can omit type in variable declaration altogether: var capital = ["Rome", "Berlin", "Lisbon"] But if the point is to just use explicit values for

Re: [noob] enums and index

2017-07-12 Thread DTxplorer
Thanks for the help Araq. The Nim enum behaves differently so I think this code reproduces better the Cpp code behaviour. const ITALY = 0 GERMANY = 1 PORTUGAL = 2 var capital: array = ["Rome", "Berlin", "Lisbon"] echo capital[PORTUGAL] Sorry

Re: [noob] enums and index

2017-07-12 Thread Krux02
I did not know this is possible. Seems very interesting.

Re: [noob] enums and index

2017-07-12 Thread Araq
No, arrays can use enums as the index type (and I use this feature all the time): type country = enum ITALY, GERMANY, PORTUGAL var capital: array[country, string] = ["Rome", "Berlin", "Lisbon"] echo capital[ITALY]

[noob] enums and index

2017-07-12 Thread DTxplorer
Sorry for the noobish question. I want to understand how using the enums like in C/C++ // Example program #include #include using namespace std; int main() { enum country {ITALY, GERMANY, PORTUGAL}; string capital[] = {"Rome", "Berlin", "Lis