Baseline: tree as shared
This commit is contained in:
commit
659c03bbf8
1471 files changed
+990535
No files matched your search
@@ -0,0 +1,19 @@
|
||||
def main():
|
||||
var message = "Hello" # Create a run-time String value
|
||||
take_text(message^)
|
||||
print(message) # error: use of uninitialized value 'message'
|
||||
```
|
||||
|
||||
This is a critical feature of Mojo's lifetime checker, because it ensures that
|
||||
no two variables have ownership of the same value. To fix the error, you must
|
||||
not use the `message` variable after you end its lifetime with the `^` transfer
|
||||
sigil. So here is the corrected code:
|
||||
|
||||
```mojo
|
||||
def take_text(var text: String):
|
||||
text += "!"
|
||||
print(text)
|
||||
|
||||
def main():
|
||||
var message = "Hello" # Create a run-time String value
|
||||
take_text(message^)
|
||||
Reference in new issue
Block a user