Ad
  • Default User Avatar

    You only def initialize when you need the object to do something when created (i.e. when .new is called). In that case, we only need to check for the name and password when we receive one so we don't need initialize to do anything.

  • Default User Avatar

    It's the most straightforward way in Ruby AFAIK. Maybe handling the case where str.nil? == true makes for a bulletproof answer, but the tests don't run the nil value, so you can get away without.