what is the point of heterogenous arrays?

后端 未结 8 1201
忘掉有多难
忘掉有多难 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:43

    There is no reason not to support heterogeneous lists. It's a limitation for technical reasons, and we don't like those.

    Not everything needs to be a class!

    In Python, a class is basically a souped up dictionary with some extra stuff anyway. So making a class User is not necessarily any clearer than a dictionary {"name": ..., "id": ...}.

提交回复
热议问题