Ad
  • Custom User Avatar

    I didn't know that: thanks for the tip :)

  • Default User Avatar

    'and' should not be used in logical comparisions, it should be used only in flow logic, for example in ruby on rails controllers you often see something like:

    def foo
      if bar
        redirect_to :root and return
      end
      
      # do semething else...
    end
    

    yes, using 'and' often gives valid results but it's bad practice because the 'and' operation has lower precedence than '&&' and you asking for strange bugs in code

  • Custom User Avatar

    also, this method returns a boolean and so it should end with a "?" like "is_santa_clausable?"

  • Custom User Avatar

    Yeah, I had that implemented but my sort code was returning a new array and that is the array I was pulling the gift from. Thanks for pointing me in the right direction.

  • Custom User Avatar

    I cannot seem to get past the fourth test on this kata. I get the following error:

    Test Failed: Incorrect queue length - Expected: 1, instead got: 2

    I have these tests currently passing before trying to submit:

    giftList = HolidayPriorityQueue.new
    length = 0

    Test.assert_equals(giftList.buyGift(), '')

    length = giftList.addGift( { 'gift' => 'Water gun', 'priority' => 1 } )
    Test.assert_equals(length, 1, 'Incorrect queue length')

    length = giftList.addGift( { 'gift' => 'BB gun', 'priority' => 2 } )
    Test.assert_equals(length, 2)

    Test.assert_equals(giftList.buyGift(), 'Water gun')

    I have re-read the instructions several times and it appears that these tests cover all the requirements. I thought maybe this was a test for invalid hashes so I added some code to verify the existence of the "gift" and "priority" keys but still got the failure above.

    Since I cannot see the creator's tests without giving up the points I could earn, I was hoping someone could point me in the right direction.

    Thanks!