Skip to content

Commit

Permalink
std.algo.cmp.castSwitch
Browse files Browse the repository at this point in the history
Params and Returns

fix

switch

review fix

a new try
  • Loading branch information
burner committed Mar 22, 2015
1 parent eba6362 commit b720202
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions std/algorithm/comparison.d
Expand Up @@ -196,21 +196,26 @@ private template indexOfFirstOvershadowingChoiceOnLast(choices...)
Executes and returns one of a collection of handlers based on the type of the
switch object.
$(D choices) needs to be composed of function or delegate handlers that accept
one argument. The first choice that $(D switchObject) can be casted to the type
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
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
all the choices are void. In that case, castSwitch itself will return void.
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
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.
*/
auto castSwitch(choices...)(Object switchObject)
Expand Down

0 comments on commit b720202

Please sign in to comment.