Ad
  • Custom User Avatar

    I got stuck with this problem too. I was using "hash.delete_if" – when I switched to the non-destructive "hash.reject" it worked fine.

    It might be worth adding a line to the kata description warning people that the input hash should not be messed with.

  • Custom User Avatar

    After forfeiting my eligibility to look at the test cases ;-; I found out why I had the issue - I modified the original hash using bang (!) methods
    When I left the hash "as is", I could pass the test.

  • Default User Avatar

    Weird - I don't see any issues with the test itself, but I'm still getting an empty hash for the first argument when then run.

  • Default User Avatar

    Is there a test case for a range of (0..9) that expects "zero (0), five (5), eight (8)"? I'm not necessarily sure it's the last one, just the last one that runs.

  • Custom User Avatar

    I've being experiencing the same issue

  • Default User Avatar

    I'm wondering if I'm missing something on the last unit test. I did puts for the hash and range being passed in and it's showing {} for the hash and 0..9 for the range. And then it's expecting "zero (0), five (5), eight (8)" for the returned string. Is this a bug?

    Thanks for the fun kata!

  • Default User Avatar

    Unfortunately, I'm having trouble remembering exactly what I did. I think it might have been as simple as adding puts statements in some places. Definitely nothing as complicated as checking the network and xhr files. Good luck - sorry I couldnt be of more help!

  • Custom User Avatar

    Hey shotop, what do you mean by basic debuggging? I couldn't find what's being passed in.
    Did you check the network and xhr files ?(Also getting an error on the third)

  • Default User Avatar

    Noob question - I just needed to do some basic debugging to see what was being passed in. Thanks!

  • Default User Avatar

    It would be good to have better test output. I am getting an error on the third test, but I have no idea what the assertion is, so I don't know what to fix. Does anyone know what the test case is for the third test?

  • Custom User Avatar

    Given that each and count have already been implemented, you shouldn't need to fully define the Bag class or its initialize method. These should already exist. Your implementation should focus strictly on every? and any further helper methods you need to create for that to work.

  • Default User Avatar

    Thank you for your response Josh. I think you are on to something and I suspect it has to do with the way I'm initializing my Bag class. I currently have this, which sets the array of arguments to the @items instance variable:

    def initialize(*args)
    @items = args
    end

    If I new up a bag, and I call bag.count or bag.each do ... I get the undefined method errors. However, if I do bag.items.count or bag.items.each, those methods work. I guess my question is, do I need to figure out a way to have count and each called on the instance of the class itself? Thanks!

  • Custom User Avatar

    The message "should execute the block for each item in the bag. why are you messing with this method? work on #every? instead" isn't indicative of an error. It's the name of that particular test, for whatever reason.

    The NoMethodErrors suggest that you are somehow passing a nil into the tests. The tests only call each on a bag object and this test passes with the default implementation, so a change you've made seems to have broken each for the Bag class.

  • Default User Avatar

    Can someone confirm that this Kata is still broken? I didn't do anything to the each method, and didn't use it as part of my every? implementation. I'm still getting the following message upon submission though. Any thoughts?

    #each:
    should execute the block for each item in the bag. why are you messing with this method? work on #every? instead.:

    NoMethodError: undefined method `each' for nil:NilClass

    NoMethodError: undefined method `each' for nil:NilClass