mirror of
https://github.com/dlang/phobos.git
synced 2025-05-14 17:05:58 +03:00
Merge pull request #3068 from burner/algo_cmp_castSwitch
std.algo.cmp.castSwitch docu
This commit is contained in:
commit
ec62f933ab
1 changed files with 10 additions and 5 deletions
|
@ -205,14 +205,10 @@ private template indexOfFirstOvershadowingChoiceOnLast(choices...)
|
||||||
Executes and returns one of a collection of handlers based on the type of the
|
Executes and returns one of a collection of handlers based on the type of the
|
||||||
switch object.
|
switch object.
|
||||||
|
|
||||||
$(D choices) needs to be composed of function or delegate handlers that accept
|
The first choice that $(D switchObject) can be casted to the type
|
||||||
one argument. The first choice that $(D switchObject) can be casted to the type
|
|
||||||
of argument it accepts will be called with $(D switchObject) casted to that
|
of argument it accepts will be called with $(D switchObject) casted to that
|
||||||
type, and the value it'll return will be returned by $(D castSwitch).
|
type, and the value it'll return will be returned by $(D castSwitch).
|
||||||
|
|
||||||
There can also be a choice that accepts zero arguments. That choice will be
|
|
||||||
invoked if $(D switchObject) is null.
|
|
||||||
|
|
||||||
If a choice's return type is void, the choice must throw an exception, unless
|
If a choice's return type is void, the choice must throw an exception, unless
|
||||||
all the choices are void. In that case, castSwitch itself will return void.
|
all the choices are void. In that case, castSwitch itself will return void.
|
||||||
|
|
||||||
|
@ -220,6 +216,15 @@ Throws: If none of the choice matches, a $(D SwitchError) will be thrown. $(D
|
||||||
SwitchError) will also be thrown if not all the choices are void and a void
|
SwitchError) will also be thrown if not all the choices are void and a void
|
||||||
choice was executed without throwing anything.
|
choice was executed without throwing anything.
|
||||||
|
|
||||||
|
Params:
|
||||||
|
choices = The $(D choices) needs to be composed of function or delegate
|
||||||
|
handlers that accept one argument. There can also be a choice that
|
||||||
|
accepts zero arguments. That choice will be invoked if the $(D
|
||||||
|
switchObject) is null.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The value of the selected choice.
|
||||||
|
|
||||||
Note: $(D castSwitch) can only be used with object types.
|
Note: $(D castSwitch) can only be used with object types.
|
||||||
*/
|
*/
|
||||||
auto castSwitch(choices...)(Object switchObject)
|
auto castSwitch(choices...)(Object switchObject)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue