Ad
  • Custom User Avatar

    I am dissapointed in the number of solutions I see that are object based.

    Disclaimer: I am a Rubyist, and as such I have only been practicing Ruby kata.

    The entire point of training with kata is to develop positive habits with practice. If you are developing in an OO language, the positive habits you want to develop are Object Oriented in nature. If the code you produce while training with kata is not Object Oriented, then you are not developing habits that will help your Object Oriented programming!

    In my opinion, Ruby is one of the greatest OO languages ever produced. We should be using the power of Objects that it provides!

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I thought about this, but I decided this kata could be performed without seriously impacting any core Classes.

  • Custom User Avatar

    It's not very idiomatic Ruby to force a regexp match to return a boolean (true/false).

    In Ruby, the Regexp class's #=~ and #match methods return nil (false-y in Ruby) if no match was found, or a Fixnum (truth-y in Ruby) which is the first match's index position in the string if a match was detected.

    Therefore, in my opinion, the test case should have read:

    Test.expect(validPhoneNumber("(123) 456-7890"), 'expected "(123) 456-7890" to be valid' )