This functionality is similar with Golang defer, java Try with resources, but it will be simpler to use.
{
auto(close) a = new FileInputStream();
auto(close) b = new FileInputStream();
}
should be closed at the end of the block.
the more general differ pattern can be implemented as well:
{
a = new FileInputStream();
defer a.close();
...
}
This functionality is similar with Golang defer, java Try with resources, but it will be simpler to use.
{
auto(close) a = new FileInputStream();
auto(close) b = new FileInputStream();
}
should be closed at the end of the block.
the more general differ pattern can be implemented as well:
{
a = new FileInputStream();
defer a.close();
...
}