If without else
- To: mathgroup at smc.vnet.net
- Subject: [mg113022] If without else
- From: Sebastian Schmitt <sschmitt at physi.uni-heidelberg.de>
- Date: Mon, 11 Oct 2010 05:17:10 -0400 (EDT)
Dear all! (I recycle my disclaimer.) I'm new to Mathematica with a background mostly in C++. Many times I have the impression that my style is not natural-Mathematica (Mathematicaesque so to say). I have a question to the usage of the If condition. In[72] := x = 2; b = 3; In[73] := If[b > 2, x = 10,]; x Out[73] = 10 In[74] := If[b > 3, x = 20,]; x Out[74] = 10 Is it good-practice to leave the "else" empty? Is x := 10 /; b > 2 what I'm looking for? Thanks in advance, Sebastian