Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    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.
    1. COI don't like this function. Why should parameter with no value should get the value of 'true'? Why not null? I think this design decision can lead to very subtle bugs. Also, why not handle the situation where parameter can have multiple values instead of selecting the 'last' value? Solution posted by David is much better.
      singulars
    2. COIt is `true` so that one can check `if (params.redirect)` or similar. If you want to differ between `true` and other value, you would use `if (params.redirect === true)`. A `null` value wouldn't help in any way that I can think of. The reason I didn't do it like David is because I value consistency over flexibility. With his method I have to check if the value is a string or an array to use its value. In my opinion, it should always be a string (the `true` value converts to `'true'` which I think is fine), or always be an array. I chose string.
      singulars
    3. COBy that account, if it was params.delete, it would be set to true and I will do something harmful. As you can see, coming up with example is easy. 'null' clearly specifies that no value exists and the decision is left to the caller what how he wants to interpret it. About multiple values, look at it this way. By eating up, you are making sure that either caller will spend time debugging why he is getting only one value OR later on come and modify the code. By returning the array upfront, caller will immediately know how to handle them. Discarding information is never good, IMHO.
      singulars
 

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