Why we need scope(success) if I can write at the end?

tamir tamir.fri at gmail.com
Fri Jan 21 05:18:15 PST 2011


or what's the differents between theese two:
void transactionalCreate(string filename) {
  string tempFilename = filename - ".fragment";
  scope(success) {
    std.file.rename(tempFilename, filename);
  }
  auto f = File(tempFilename, "w");
}
and:
void transactionalCreate(string filename) {
  string tempFilename = filename - ".fragment";
  auto f = File(tempFilename, "w");
  std.file.rename(tempFilename, filename);
}


More information about the Digitalmars-d-learn mailing list