I will give the C-style “parentheses” pseudocode to show what I would like to express differently:
for (int i = 0; i < n; i++) { if (i == 3 || i == 5 || i == 982) { assertTrue( isCromulent(i) ); } else { assertFalse( isCromulent(i) ); } }
The for loop is not very important, this is not a question of my question: I would like to know how I could rewrite what is inside the loop using Scala.
My goal is not to have the shortest code: this is because I would like to understand what manipulations can be done on method names (?) In Scala.
Can you do something like the following in Scala (the next is still some kind of pseudo code, not Scala code):
assert((i==3 || i==5 || i==982)?True:False)(isCromulent(i))
Or even something like this:
assertTrue( ((i==3 || i==5 || i==982) ? : ! ) isCromulent(i) )
Basically, I would like to know if the test result (i == 3 || i == 5 || i == 982) can be used to send between two methods or to add a "not" to the expression.
I do not know if this makes sense, please be kind (see my profile) :)
source share