Untitled

mail@pastecode.io avatar
unknown
d
2 years ago
670 B
0
Indexable
Never
// Class constructor test thing

// Regular old unsafe
this(Game game) {
    super(game);
    this.world = new World(100, 100);
    atlas = cache.get("atlas").get();
    this.exporter = new MapExporter(this);
}


// Wow, we're being safe
@safe:

@trusted
this(Game game) {

    // Something unsafe goes here like this:
    super(game);

    // Single line safety
    (() @safe => writeln("test"))();

    // Safe scope
    (() @safe => ({
        writeln("I am being safe");
        writeln("blorp shmoop");
    }))();

    // Back to trusted unsafe
    this.world = new World(100, 100);
    atlas = cache.get("atlas").get();
    this.exporter = new MapExporter(this);
}