Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For APIs which don't support this, you can still use `using` by using DisposableStack:

    using disposer = new DisposableStack;
    const resource = disposer.adopt(new Resource, r => r.close());
This is still simpler than try/catch, especially if you have multiple resources, so it can be adopted as soon as your runtime supports the new syntax, without needing to wait for existing resources to update.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: