Logo

Programming-Idioms

History of Idiom 11 > diff from v7 to v8

Edit summary for version 8 by :

Version 7

2015-08-22, 07:06:06

Version 8

2015-08-22, 07:08:27

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
Code
element := x.Items[random(x.count)];
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