You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Associated functions, or "static methods" in some languages, are functions belonging to a type namespace, but not requiring an instance of that type as a self parameter unlike methods.
Associated functions would be useful both for avoiding collisions in global namespace and potentially making traits more powerful by allowing a trait to specify required associated functions.
The proposed syntax is:
struct Foo {
// A function defined within a struct definition without a self parameter should be
// considered an associated function.
fun bar() {
// ...
}
}
fun main() {
// A new namespace navigation operator `::`.
Foo::bar();
}
The text was updated successfully, but these errors were encountered:
Associated functions, or "static methods" in some languages, are functions belonging to a type namespace, but not requiring an instance of that type as a
self
parameter unlike methods.Associated functions would be useful both for avoiding collisions in global namespace and potentially making traits more powerful by allowing a trait to specify required associated functions.
The proposed syntax is:
The text was updated successfully, but these errors were encountered: