📜  为什么 getter 和 setter 很重要 ruby 代码示例

📅  最后修改于: 2022-03-11 15:04:49.232000             🧑  作者: Mango

代码示例1
In a Ruby class we may want to expose the instance variables (the variables that are defined prefixed by @ symbol) to other classes for encapsulation. ... Getter methods are used to get the value of an instance variable while the setter methods are used to set the value of an instance variable of some class