Skip to content
Advertisement

Tag: type-coercion

I’ve got an object that is basically an int with some extra properties. Can I coerce it into an int when it’s used as a list index?

Context: I’m making a game that happens in a maze made of square tiles and almost everything, from movement to attacks, involves directions, which are mostly used to index lists. Subtracting or adding to directions is an easy way to turn left or right, but I always have to check that they are still within bounds, and I would like

Advertisement