📜  调用 getter 与局部变量 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:59.001000             🧑  作者: Mango

代码示例1
For most programming languages and envs, consider:

- Memory footprint: Negligible (4-8 bytes?), the local variable is a reference.
- Performance: Depends on the computation of the getter. If a simple getter,
it wont matter because of compiling optimizations.
- DRY: local wins.
- Correctness: matters in multi threaded programs, value of getter may change.

In general try to use local variables if possible.
If your getter is a simple computaiton, can also use it. Avoid long object 
chaning though!