

Which
Details

- Which has attribute HoldAll.
- If any of the testi evaluated by Which give neither True nor False, then a Which object containing these remaining elements is returned unevaluated. »
- You can make Which return a "default value" by taking the last testi to be True.
- If all the testi evaluate to False, Which returns Null.
Examples
open all close allBasic Examples (1)
Scope (4)
Programming Behavior (3)
Symbolic Transformations (1)
Properties & Relations (2)
Use Which rather than a nested if-then-elseif chain:
Use PiecewiseExpand to convert Which to Piecewise:
Tech Notes
Related Guides
History
Introduced in 1988 (1.0)
Text
Wolfram Research (1988), Which, Wolfram Language function, https://reference.wolfram.com/language/ref/Which.html.
CMS
Wolfram Language. 1988. "Which." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Which.html.
APA
Wolfram Language. (1988). Which. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Which.html
BibTeX
@misc{reference.wolfram_2025_which, author="Wolfram Research", title="{Which}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/Which.html}", note=[Accessed: 08-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_which, organization={Wolfram Research}, title={Which}, year={1988}, url={https://reference.wolfram.com/language/ref/Which.html}, note=[Accessed: 08-August-2025]}