what is the point of heterogenous arrays?

后端 未结 8 1202
忘掉有多难
忘掉有多难 2020-12-16 13:43

I know that more-dynamic-than-Java languages, like Python and Ruby, often allow you to place objects of mixed types in arrays, like so:

[\"hello\", 120, [\"w         


        
8条回答
  •  不知归路
    2020-12-16 14:48

    Eterogenous lists are very useful. For instance, to make the game of snake, I can have a list of blocks like this: [[x, y, 'down'], [x1, y1, 'down']] instead of a class for the blocks, and I can access faster to every element.

提交回复
热议问题