Sunday, 8 September 2013

How to check any two parameters of a function are null

How to check any two parameters of a function are null

Suppose I have a function that takes three parameters. Of course I could
check that any two parameters of this function is null in this way.
returnType function(p1, p2, p3){
if((p1 && p2 == null) || (p2 && p3 == null) || (p3 && p1 == null)){
return;
}
}
But this is rather cumbersome and wouldn't scale for larger number of
parameters.
What would be the elegant way to do this?
Thanks in advance.

No comments:

Post a Comment