You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In base R, [[ sometimes returns an error and sometimes returns NULL:
row[[col]]
Zero-length
OOB (int)
OOB (chr)
Missing
NULL
NULL
NULL
NULL
NULL
Atomic
Error
Error
Error
Error
List
Error
Error
NULL
NULL
pluck() eliminates this inconsistently by (effectively) always return NULL. We need a strict equivalent that eliminates the inconsistency in the opposite direction: by always throwing an error.
So, I also have this working for environments and S4 objects. For environments, it errors if the object doesn't exist in the environment, and for S4 if the object doesn't have the desired slot. This would the desired behaviour, right?
The other big one is indexing by function, but (correct me if I'm wrong) I don't think we can really make this strict as it relies on whatever that function's behaviour is.
Activity
hadley commentedon Mar 29, 2018
We could call it
chuck()orsuck()daniel-barnett commentedon May 3, 2018
Were you thinking something like the following (but without the
strictparameter)? If so, I can clean it up and make a PR.hadley commentedon May 3, 2018
Exactly!
hadley commentedon May 3, 2018
A PR would be great 😄
daniel-barnett commentedon May 10, 2018
So, I also have this working for environments and S4 objects. For environments, it errors if the object doesn't exist in the environment, and for S4 if the object doesn't have the desired slot. This would the desired behaviour, right?
The other big one is indexing by function, but (correct me if I'm wrong) I don't think we can really make this strict as it relies on whatever that function's behaviour is.
hadley commentedon May 10, 2018
That all sounds correct to me
Merge pull request #522 from daniel-barnett/pluck-strict