Zengqh Mansion wrote in post #982758:
> thanks very much.
> i was reading the book "programming ruby".
> it said "def attribute=(new_attribute)", can be used attribute as if
> it's public variables, i think i was wrong.

Do not have the book, but I'm guessing that statement was made in a 
particular context.

def attribute=(new_attribute) does allow you to use attribute as a 
public variable, when you are setting new value for attribute.

If you have subsequently proceeded to code def attribute as Peter has 
suggested above, that will allow you to use your attribute as a public 
variable when it comes to getting value of attribute.

Nevertheless, attr_accessor, attr_reader and attr_writer should be 
betterfor getter and setter.

-- 
Posted via http://www.ruby-forum.com/.