示例工程 14-metatables-and-operators
14-metatables-and-operators/01-vector-arithmetic/README.md
# 01 · vector-arithmetic
**演示**:`__add`、`__mul`、`__tostring` 让表支持向量运算。
**运行时**:`lua54`、`luajit`。
**运行**:
```sh
.tools/bin/lua54 scripts/run-example.lua examples/14-metatables-and-operators/01-vector-arithmetic
.tools/bin/lua54 scripts/test-example.lua examples/14-metatables-and-operators/01-vector-arithmetic
```
**预期输出**(lua 5.4.9 / macOS arm64):
```text
sum=(4,6) scaled=(4,6)
```
**看点**:元方法返回新表;运算不修改操作数。
**注意**:`__add` 查找左操作数优先,右操作数补位。