Ruby Habits

Ways to avoid typos

  • Hash#fetch to avoid typo

    hash[:sometihng] => nil
    hash.fetch(:sometihng) => KeyError
    
  • Constant to avoid typo. NameError when typo

  • attr_* raises NoMethodError when typo