We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c8bccd6 commit e9626a4Copy full SHA for e9626a4
mojo/.gitignore
@@ -0,0 +1,5 @@
1
+# pixi environments
2
+.pixi/*
3
+!.pixi/config.toml
4
+pixi.lock
5
+pixi.toml
mojo/deinit.mojo
@@ -0,0 +1,20 @@
+@fieldwise_init
+struct Balloon(Writable):
+ var color: String
+
+ fn write_to(self, mut writer: Some[Writer]):
6
+ writer.write(String("a ", self.color, " balloon"))
7
8
+ fn __del__(deinit self):
9
+ print("Destroyed", String(self))
10
11
12
+def main():
13
+ var a = Balloon("red")
14
+ var b = Balloon("blue")
15
+ print(a)
16
+ # a.__del__() runs here for red Balloon
17
+ a = Balloon("green")
18
+ # a.__del__() runs immediately because green Balloon is never used
19
+ print(b)
20
+ # b.__del__() runs here
0 commit comments