Getter 常指在面向对象编程里用于“获取/读取属性值”的方法(也叫 accessor,取值器/取值方法)。在日常英语中也可泛指“获得某物的人”,但最常见用法出现在编程语境中。
/ˈɡetər/
I wrote a getter to read the user’s name.
我写了一个 getter 来读取用户的名字。
The class exposes its fields through getters, which helps keep the internal state controlled.
这个类通过 getters 暴露字段,这有助于让内部状态保持可控。
来自动词 get(获得、得到)+ 表示“做某事的人/物”的后缀 -er,字面意思是“获得者/获取者”。在软件工程中引申为“用来获取某个值的方法”。