Skip to content

Commit db4d17c

Browse files
committed
Update FAQ vignette
1 parent 7c04796 commit db4d17c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

vignettes/FAQ.Rmd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,15 @@ cpp11::environment create_environment() {
153153
#### 9. How do I assign and retrieve values in an environment? What happens if I try to get a value that doesn't exist?
154154

155155
Use `[]` to retrieve or assign values from an environment by name.
156-
If a value does not exist it will return `R_UnboundValue`.
156+
If a value does not exist, it will error.
157+
To check for existence ahead of time, use the `exists()` method.
157158

158159
```{cpp11}
159160
#include <cpp11.hpp>
160161
161162
[[cpp11::register]]
162163
bool foo_exists(cpp11::environment x) {
163-
return x["foo"] != R_UnboundValue;
164+
return x.exists("foo");
164165
}
165166
166167
[[cpp11::register]]

0 commit comments

Comments
 (0)