|
Post by fwiss on Oct 26, 2011 8:21:56 GMT -5
is there a way to make a constant expression
So I have a large if..then statement along the lines of if (choice == "1" || choice == "cat") statement; else if (choice == "2" || choice == "car") other_statement
This goes on for a long while. I was hoping I could make a constant of the type
const expression = "1" || "cat"; to shorten it up. How would I do this?
|
|
|
Post by shadow008 on Oct 26, 2011 19:04:57 GMT -5
How about when declaring/inputting "choice", change the value there, such as:
input choice value
if (choice == "cat") set choice to "1" else if (choice == "car") set choice to "2" ect
That way, when it comes to your massive if/then/elseif statement, you can shorten that up (and other ones you may encounter) and use something like:
if (choice == "1") statement; else if (choice == "2") other_statement
This way, instead of having to do the extra inclusive or every time you need to check the two values, you only have to use it in the deceleration.
Will that help?
|
|
|
Post by fwiss on Oct 27, 2011 5:43:05 GMT -5
Never thought of it that way! Hmm, it at least increases readability, though not to the extent a constant would.
Also, ewwww Dubstep >_<.
|
|
|
Post by fwiss on Oct 27, 2011 16:25:52 GMT -5
Anyone else have any other suggestions?
|
|
|
Post by aphoticgenesis on Oct 27, 2011 23:47:31 GMT -5
Anyone else have any other suggestions? Smoke a blunt.
|
|
|
Post by fwiss on Oct 28, 2011 6:14:43 GMT -5
aphoticgenesis: The solution you provided did not work. I believe you are taking a completely different approach to the problem at hand. Also, express answers that you yourself cannot implement in C++ in pseudocode. Thank you for your time!
|
|
|
Post by Supermonkey on Oct 28, 2011 16:34:18 GMT -5
|
|
|
Post by fwiss on Oct 28, 2011 20:23:03 GMT -5
Wow! I'm tired, so I'm only going to focus on the concept and not the application yet, but that's useful for more than just the situation I described!
|
|