Open
Description
let text = " the quick brown ";
{
fn trim(x) {
"..." <> x <> "..."
}
// Calls the shadowed trim because Any matches String inside the scope.
print(text.trim());
}
In the example above the best match inside the current scope is used which is probably good!
let text = " the quick brown ";
fn trim(x) {
"..." <> x <> "..."
}
// Calls the original trim because String is a better match inside the same scope?
print(text.trim());
In this example the best match in the current scope is used which is probably fine but at little confusing?
let text = " the quick brown ";
let trim = fn(x) {
"..." <> x <> "..."
}
// Calls the overloaded trim :mild-panic-intensifies:
print(text.trim());
In this example the let binding for trim
creates an implicit scope where the new trim
shadows the existing trim
and the call to trim
only finds the last version. This is probably wrong 😢