carbon-lang
carbon-lang copied to clipboard
Inferring parameter types with `auto`
In C++, it is possible to infer parameter types and return types of functions using the auto
keyword:
auto square(auto x){
return x*x;
}
I tried to use this keyword in Carbon, but this program didn't compile successfully:
package sample api;
fn Square(x: auto) -> auto {
return x * x;
}
fn Main() -> i32 {
return Square(12);
}
Will this feature be supported in Carbon?