23 lines
528 B
Mojo
23 lines
528 B
Mojo
# probe: reassigned in every pass and read after the loop: when does each old value die?
|
|
struct L(Copyable, Movable):
|
|
var n: String
|
|
|
|
def __init__(out self, n: String):
|
|
self.n = n
|
|
print("init", n)
|
|
|
|
def __init__(out self, *, deinit move: Self):
|
|
self.n = move.n^
|
|
print("move", self.n)
|
|
|
|
def __deinit__(deinit self):
|
|
print("bye", self.n)
|
|
|
|
|
|
def main():
|
|
var a = L("0")
|
|
for i in range(2):
|
|
a = L(String(i + 1))
|
|
print("pass", i)
|
|
print("after loop", a.n)
|