ScopedValue: Capturing current bindings

Daniel Avery danielaveryj at gmail.com
Tue May 23 16:09:56 UTC 2023


Would it not be sufficient to use a local variable to capture the current
binding?

```
ScopedValue<String> testValue = ScopedValue.newInstance();

ScopedValue.where(testValue, "OuterValue", () -> {
  String value = testValue.get();
  withBinding(String.class, () -> value, () -> {
    ScopedValue.where(testValue, "InnerValue", () -> {
      System.out.println(getByType(String.class));
    });
  });
});
```

- Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230523/968a06f5/attachment.htm>


More information about the loom-dev mailing list