4
$\begingroup$

I have the following Code:

Dynamic[Which[infoquestion == "Yes", 
"Please select the calculator that fits your needs best from our \
page", infoquestion == "No", 
"Thanks for visiting us. Please contact our team at +41 77 777 77 \
77 if you want to set up the loan.", True, "Please choose Yes or No"]]

My problem is, that I need to show "Please choose Yes or No", before something is evaluated without pre-defining the variable infoquestion. Is that somehow possible? I tried with True, but this does not apply to unevaluated input.

$\endgroup$

1 Answer 1

8
$\begingroup$
Dynamic[Which[infoquestion === "Yes", "Please select the calculator that fits your needs best from our page",
  infoquestion === "No", "Thanks for visiting us. Please contact our team at +41 77 777 77 77 if you want to set up the loan.",
  True, "Please choose Yes or No"]]

Which remains unevaluated if it cannot determine the True or False value of its conditions. However, === (SameQ) is perfect for this, as it is guaranteed to evaluate to either True or False for any input based on structural equivalence. == notably does not make this guarantee as it would interfere with its usage in symbolic algebra.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.