mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
27 lines
394 B
Plaintext
27 lines
394 B
Plaintext
import std::io;
|
|
|
|
struct Foo
|
|
{
|
|
int[3] elements;
|
|
}
|
|
|
|
fn int Foo.at(Foo *vector, float index) @operator([])
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
fn int Foo.len(Foo *vector) @operator(len)
|
|
{
|
|
return 3;
|
|
}
|
|
|
|
fn void main()
|
|
{
|
|
|
|
Foo f;
|
|
io::printfn("%s", f[12.2]);
|
|
foreach (int i, value : f) // #error: Only types indexed by integers or enums may
|
|
{
|
|
io::printfn("v[%s] = %s", i, value);
|
|
}
|
|
} |