What does length(%HASH) produce if you have thirty-seven random keys in a newly created hash?

Q

What does length(%HASH) produce if you have thirty-seven random keys in a newly created hash?

✍: Guest

A

5
length() is a built-in prototyped as sub length($), and a scalar prototype silently changes aggregates into radically different forms. The scalar sense of a hash is false (0) if it's empty, otherwise it's a string representing the fullness of the buckets, like "18/32" or "39/64". The length of that string is likely to be 5. Likewise, `length(@a)' would be 2 if there were 37 elements in @a.

2013-09-13, 1924👍, 0💬