我有这样的代码:
letsdoit(something,'abcd');
letsdoit(something,'asdfasdf');
letsdoit(something,'gagaga');
如果可能的话,我希望它只有一行简单的逻辑,比如:
(letsdoit(something,'abcd')) OR (letsdoit(something,'asdfasdf')) OR (letsdoit(something,'gagaga'));
因此,它有33%的机会选择这三个中的任何一个。或者:
(letsdoit(something,'abcd')) OR (letsdoit(something,'asdfasdf'))
因此,它有50%的机会选择左边或50%的机会选择正确的东西。
我的问题是:
发布于 2018-08-12 22:20:46
function RandomChooseString(const A: array of string): string;
begin
Result := A[Random(Length(A))]
end;
letsdoit(something, RandomChooseString(['aaa', 'bbb', 'ccc']));
https://stackoverflow.com/questions/51809520
复制相似问题