3 ms·
Would this be considered legal? [ [1,2], ["a", "b"] ]
by Comkid 14y ago
Would this be considered legal?
[ [1,2], ["a", "b"] ]
- mikegirouard 14y agoThe README says not to mix data types because "that's stupid" (which I don't know if I agree with); but I don't know if that answers your question. You have an array of array, which at that level, satisfies the spec. The children individually keep types contained. That said, I'm going to assume the intent is to not allow that.
- Comkid 14y agoWould it be okay to understand arrays as integer indexed keys? For example, wouldn't that mean something like: array = [ [1,2], ["a", "b"] ] Be the same as this: [array] 0 = [1,2] 1 = ["a", "b"]
- kazoolist 14y agoI wondered the same thing. "No, you can't mix data types, that's stupid" leaves it ambiguous. If you parse the outer array as just "array of arrays" (as each element is an array), you're not "mixing". But if we're supposed to be parsing it as "arrays of arrays of _type_", then we are mixing.
- burke 14y agoIt's unspecified, I guess, but if you want to read into the spirit of it, which is to make it trivially-supportable by type-nazi languages such as haskell, you either get a [[Int]] or a [[String]].
- mbetter 14y agoI don't know how much it is going to help as you're going to have to wrap the values anyway to get a Map with heterogeneous values.
- rjsamson 14y agoThis has now been clarified - it is legal
- burntsushi 14y agoWhich I find to be quite odd [1]. Data types in `TOML` can be mixed at the level of the hash table. Arrays ought to be homogeneous. [1] - https://github.com/mojombo/toml/issues/28 https://github.com/mojombo/toml/issues/28