3 ms·
Closer to idomatic Ruby: state = behavior.respond_to? :init ? behavior.init : {} Asking an object if something is "callable" in Ruby is probably unnecesarily
by jack_jennings 9y ago
Closer to idomatic Ruby:
state = behavior.respond_to? :init ? behavior.init : {}
Asking an object if something is "callable" in Ruby is probably unnecesarily verbose, as you are most likely dealing with a method for any attribute access.