Rust is statically typed, so this is an error, it's not possible (unless you use some kind of variant):

Not quite clear in the example but just add an extra line after if block.

log "do you want to add strings or ints?";
auto use_str = input.readline == "strings";
if (use_str) {
    a = "hello ";
    b = "world!";
} else {
    a = 1;
    b = 1;
}
auto c = b - a; // wah?

log a + b;

...

Bye,
bearophile

Already love it, lowercase ftw!
Although built-in logging is nice, both the name and the operator of logging are very bad choices.
Especially for a standard library.

Reply via email to