Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would recommend writing it in a more reusable way. The fact that all parameters must be given should not be hard-coded into the logic of the parameter parser. You should just check for that in the end, right before you "proceed with rest".</p> <p>What I generally do in such cases is the following:</p> <p>First of all, for each one of the possible arguments I have some variables which contain reasonable defaults (so that the argument can be omitted) a trivial example of which would be <code>bool argument_x_given = false;</code> </p> <p>So, I loop over the given arguments, and inside the loop I check the current argument against each and every one of the possible arguments, to find which one it is. If not found, we have an error. If a matching argument is found, then I parse the rest of the argument (the stuff after the ':') and I set the variables which are associated with the argument. While doing this, I check to make sure that the argument is not a duplicate. In the trivial example here, that would be <code>if( argument_x_given ) { --error-- } else { argument_x_given = true; ... }</code>.</p> <p>Finally, once the loop is done, I make sure that all the required arguments were given.</p> <p>So, what I am trying to say is that you will not gain anything by comparing the string arrays, because you are going to have to make sense out of each and every one of your arguments anyway, and also comparing the string arrays is like trying to take advantage of a situation which is very specific to the problem at hand and not reusable at all.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload