We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7c04796 commit db4d17cCopy full SHA for db4d17c
vignettes/FAQ.Rmd
@@ -153,14 +153,15 @@ cpp11::environment create_environment() {
153
#### 9. How do I assign and retrieve values in an environment? What happens if I try to get a value that doesn't exist?
154
155
Use `[]` to retrieve or assign values from an environment by name.
156
-If a value does not exist it will return `R_UnboundValue`.
+If a value does not exist, it will error.
157
+To check for existence ahead of time, use the `exists()` method.
158
159
```{cpp11}
160
#include <cpp11.hpp>
161
162
[[cpp11::register]]
163
bool foo_exists(cpp11::environment x) {
- return x["foo"] != R_UnboundValue;
164
+ return x.exists("foo");
165
}
166
167
0 commit comments