[Jprogramming] Default in control structure?
Sprague, Webb (OFM)
Webb.Sprague at ofm.wa.gov
Sat May 22 02:32:54 HKT 2010
Hi all,
Does J have a conditional control structure such that 1 of N options, with a way to specify a default if none of the conditions are met?
In matlab, for example:
if (x==4)
disp("4")
elseif (x==5)
disp("5")
else
disp('other')
endif
One could also use a switch/ case/ otherwise construct.
This construct is especially important in defensive programming, and is way better than just have a chain of if statements, since it guarantees that only one of the conditional blocks is executed.
Thanks!
---
W. Webb Sprague
Forecast Analyst
Office of Financial Management, Forecast Division
GA Bldg., 3rd Floor, 318-K
PO Box 43113
Olympia, WA 98504-3113
Tel: 360-902-0634
Fax: 360-725-5174
webb.sprague at ofm.wa.gov
http://www.ofm.wa.gov/pop/
More information about the Programming
mailing list