• You're trying to pass it off as being about arrays, but it's actually about mimicking java syntax and what-would-happen-if-running-this-exact-code-in-java.
    The focus of the description doesn't match the kata.

    If we were to make an array that behaved like java ones, then yes, you'd be able to put a bool in an int array, because a bool is an int and if you have such a relationship in java, then you get to put the child class in an array of the parent class. The focus, then, is not on the array, but on the java-simulation.

  • You didn't have to complete this kata. If you want me to be more 'honest,' you're gonna have to tell me how. I don't see how I misled anyone.

  • Look, it's my kata—you don't have to like how I built it. For the purposes of this kata, bools and ints are different classes.

  • I didn't do anything to resolve your issue. Your code must have had an error. And as this is emulating other languages, I would prefer Truth (bools are not ints). I really don't understand why this (bool as an int) has to be an issue.

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

  • There is a reason: they are integers (bool is a subclass of int).

    You are violating all oop principles and teaching bad practices.

    P.S. you mix data types "so loosely" in all languages with oop support.

  • I can't pass the tests. Something weird seems to be going on.
    Whenever the __setitem__ method is called (i.e. a[3] = "blarf"), it gets called twice. The first time all is well, but then it appears to get called immediately a second time, with the same values, but something has happend to the instance so that I get an AttributeError:

    AttributeError: 'Array' object has no attribute 'T'
    

    T is the instance attribute that stores the data-type. It exists (it's set in __init__()), as is evidenced by the fact that the first call works without errors, but the second call either calls this on the Class or does something funky, because the same instance claims not to have that attribute anymore. If I set a class attribute T, it works without the error, however this is now a class wide attribute that overshadows instance types. I can set and get all day long in local tests without issues.

  • The reason why this is pointless and stupid is that it's a shallow syntax imitation plus introducing the problem of some types behaving differently. In terms of what it does, it's got nothing to do with arrays. The primitive values aren't even primitive, there's nothing about value size which is the whole idea.

    And what language with typed arrays considers string to be primitive?!

    If you consider java, there are nullable types, but there are not type-or-null arrays. Instead that is an array of that type, null being a possible value of that type since it is... nullable.

    When I say Array I mean an Array as they are in many other languages: you define the length when the array is created, and then you can set items by index and retrieve items by index. That's about it.

    This is a lie. We're not creating arrays as they are in other languages, we're creating a java simulator. We are to pretend that some arbitrarily chosen types are primitive. We don't have nullable types, but we gotta simulate that behaviour. It would help if the description was more honest about the intention instead of hiding behind another concept.
    The kata might even make some sort of sense if it was presented as simulate-your-third-hour-of-learning-java and re-enacting the quirks one would encounter. But then in terms of what the user is supposed to write in code... it's actually about playing around with a couple python __dunder__\ methods. Arrays?Java? they don't seem too important to that goal, especially not when things are as confused as they are.

  • Got it. I'm dumb. Fixed.

    I wish just 1 time—1 time!—I could post a kata with nothing wrong with it on the first try.

    I'm pretty damn sure now that I've fixed everything now. The problems stemmed from the fact that I copy pasted my solution into the test fixtures and renamed the classes without renaming some of the components of the class methods.

  • The complete traceback for the metaclass NameError is this:

    Traceback (most recent call last):
      File "tests.py", line 28, in <module>
        class ArrayTest(list, metaclass=MetaArray):
    NameError: name 'MetaArray' is not defined
    
  • Sorry, I used the wrong variable in the test cases (regarding typ attribute). I meant to use the test variable using my solution rather than the user's.

    As for the NameError, I'm not sure how you could possibly be getting that error. I don't even have a MetaArray class defined in the test cases, only a MetaArraySolution. And even then, it isn't referenced in test cases. Would you mind sharing your code that results in this error?

    Also, serious plaudits for completing this kata even in its present very imperfect state with these issues. And thanks for the feedback.

    Edit: I may or may not have fixed it. I think I did.

  • True and False are recognized as ints by python but for the purposes of this kata there's no reason they can't be a separate data type. I really wanted this array class to work kinda like it does in Java. You don't generally mix data types so loosely in pretty much any other language. If you really feel that it's necessary, I'll specify in the description that for this kata, True and False are not to be considered ints, but I really don't think so.

    Also, type(True) is bool.

  • "Cannot assign item of type bool to Array of type int"

    Why? A bool is an int. An array of interger must accept all integers, including True and False.

    >>> isinstance(True, int)
    True
    >>> isinstance(False, int)
    True
    
  • Several issues in main test suite:

    • NameError: Metaarray is not defined.
    • AttributeError: user's class is expected to have attribute typ, even though it is not mentioned in the description.

    P.S. Both of these cases should not be enforced to user. Only the requirements, mentioned in the description, must be explicitly checked.

  • This wasn't raised as an issue. I didn't even get a notification. If it's a problem with the kata, it's an issue. If it's a question about the kata, then it's a question. And you can't blame me for not fixing a problem that I didn't even know about.

    It should work now. I just forgot in one instance that the PHP concatenation operator is a . and not a +. So I just had to change 1 character :p

    https://www.codewars.com/kumite/60189c4d6d5a1100236d05ab?sel=60220ace2b35dd0017c1ce61

  • Loading more items...