Yeah, D programmers rearly utilize with even with limited scope it can hide the origin. The main thing here is to create a scope to automatically call close() like in Python.
with
close()
{ auto f = File("text.txt", "w"); f.write(["my" , "name" , "is" , "Jesse"].join(","), "!"); }
But D also provides an explicit cleanup since, not all cleanup is the same, and not everything is expected to clean up at scope exit
{ auto f = File("text.txt", "w"); scope(exit) f.close(); f.write(["my" , "name" , "is" , "Jesse"].join(","), "!"); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yeah, D programmers rearly utilize
with
even with limited scope it can hide the origin. The main thing here is to create a scope to automatically callclose()
like in Python.But D also provides an explicit cleanup since, not all cleanup is the same, and not everything is expected to clean up at scope exit