What is the best (most compact) way to hand this situation: One or more arguments to a method call depends on some condition, while the rest of the arguments are identical?
For example-- you want to
DeathRay mynewWpn = new DeathRay(particle.proton, chassisColor.BLACK, oem.ACME)
if
enemy_composition == nature.ANTIMATTER
but
DeathRay mynewWpn = new DeathRay(particle.anti-proton, chassisColor.BLACK, oem.ACME)
if
enemy_composition == nature.MATTER
Obviously you can if-else
but it looks unnecessarily long when there are a lot of arguments or more than one conditional argument. I have also done this creating an argument with an if-else
beforehand and then calling the method. Again, that seems kind of clunky. Is there some sort of inline syntax similar to an Excel if-statement?