Re: compiler error when trying to get random key from AA

2020-01-25 Thread mark via Digitalmars-d-learn
In the end I used this line since I'm not fussy about the rnd for this: auto word = compatibles.byKey.array.choice; Thank you!

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 09:18:01 UTC, Basile B. wrote: On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word =

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word = aa.byKey.choice(rnd); writeln(word); } And in the D

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word = aa.byKey.choice(rnd); writeln(word); } And in the D

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 09:06:53 UTC, mark wrote: On Saturday, 25 January 2020 at 08:59:23 UTC, Basile B. wrote: On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: [...] [snip] [...] rndGen is a range. Use `auto word = aa.byKey.choice(rnd.front())` as index instead. Then

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 08:59:23 UTC, Basile B. wrote: On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: [...] rndGen is a range. Use `auto word = aa.byKey.choice(rnd.front())` as index instead. Then `rndGen.popFront()` to advance. no sorry, I didn't read and thought you

Re: compiler error when trying to get random key from AA

2020-01-25 Thread mark via Digitalmars-d-learn
On Saturday, 25 January 2020 at 08:59:23 UTC, Basile B. wrote: On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word =

Re: compiler error when trying to get random key from AA

2020-01-25 Thread Basile B. via Digitalmars-d-learn
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word = aa.byKey.choice(rnd); writeln(word); } And in the D

compiler error when trying to get random key from AA

2020-01-25 Thread mark via Digitalmars-d-learn
I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word = aa.byKey.choice(rnd); writeln(word); } And in the D playground it gives this error: onlineapp.d(8): Error: template