Hacker News new | ask | show | jobs
by jack_jennings 3207 days 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.