Can anyone let me know if the compiler gives me incorrect warnings:
var s: String = ""
var t: Bool = True
if t:
s = "s is used"
else:
s = "s is also used"
print(s)
$ mojo life.mojo
life.mojo:2:21: warning: assignment to 's' was never used; assign to '_' instead?
var s: String = ""
^
s is used
duck_tape
(Seth Stadick)
2
It’s because you initialize and then reassign s
right away.
var s: String
var t: Bool = True
if t:
s = "s is used"
else:
s = "s is also used"
print(s)
Will remove the warnings.
1 Like
system
(system)
Closed
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.