Logo

Programming-Idioms

History of Idiom 11 > diff from v10 to v11

Edit summary for version 11 by :

Version 10

2015-08-25, 20:25:37

Version 11

2015-08-25, 20:25:50

Idiom #11 Pick a random element from a list

List x must be non-empty

Idiom #11 Pick a random element from a list

List x must be non-empty

Imports
classes
Imports
classes
Code
element := x.Items[random(x.count)];
Code
element := x.Items[random(x.count)];
Comments bubble
If x is a TList or TStrings -descendent
Comments bubble
If x is a TList or TStrings -descendent
Origin
http://www.programming-idioms.org/idiom/11/pick-a-random-element-from-a-list/618/delphi
Origin
http://www.programming-idioms.org/idiom/11/pick-a-random-element-from-a-list/618/delphi