2 ms·
One way you could think of it is, what if you’re using a library and it has a method supporting “using” functionality. Now you can just call “await using foo(…
by jasonjmcghee 3y ago
One way you could think of it is, what if you’re using a library and it has a method supporting “using” functionality.
Now you can just call “await using foo(…)”, rather than the try/finally pattern, and get the automatic dispose call on leaving scope.
Kotlin has “use” with a similar effect, and i much prefer it over try/finally. Might be worth checking it out too.