Is there an easy way to bulk assign instance variables
def initialize(title: nil, label_left: nil, label_right: nil, color_set: nil)
@title = title
@tadman provided already an excellent answer to this, but here is one more: If you are willing to dispense with named parameters, you could do it like this:
def initialize(*args)
@title, @label_left, @label_right, @color_set, *nada = args
fail "Too many arguments" unless nada.empty?
end
[UPDATE: Fixed the code, according to the comment given by @sawa].