Import
import decides how external names enter the file: some bring a prefix, some bring short names, and some only activate extension methods. Each of the nine forms has its own job.
The Forms at a Glance
| Form | What you get | Typical use |
|---|---|---|
import Mod; | prefix Mod (no short names injected) | qualified access Mod.f() |
import Pkg::Mod; | cross-package module prefix | qualified access across packages |
import Mod as A; | prefix renamed to A | disambiguation, shortening |
import Mod.*; | short names for all top-level symbols of the module | direct short-name use |
import Mod.{X, Y as Z}; | short names for selected symbols (per-symbol aliasing allowed) | precise injection |
import Mod.X; | equivalent to Mod.{ X } | precise injection |
import Mod.X as Y; | equivalent to Mod.{X as Y} | precise injection |
import Mod.extension; | no names (activation only) | extension methods only |
import Pkg::*; | every module name in the package as a prefix | bulk cross-package |
Prefixes, Wildcards, and Aliases
import Math.*;
import Collections.*;
func Bigger<T>(a: T, b: T) where T: Ordered -> T
{
if a < b
{
return b;
}
return a;
}
func main() -> int
{
print(Bigger(3, 9));
print(Math.Max(2, 5), Math.Abs(-4));
val s = new set<string>();
s.Add("a");
print(s.Contains("a"));
return 0;
}9
5 4
True编写到此Written up to here
本页其余部分尚未完成,内容随时补充。The rest of this page is not written yet; more content will follow.
Last updated on October 11, 2026
