It is absolutely safe, and I do it all the time. However, I think this is the best style for setting the attributes of an object as follows:
class Parser attr_accessor :config, :html def initialize(config, html) self.config = config self.html = html end ... end
When you do this, your code will use the setter methods provided by attr_acessor. This way you always have a consistent way of accessing your variables.
source share