Andrea Fontana:

Is empty() there just to match range "interface"?

Right, it's useful for arrays to fulfill the range protocol.


length needs no import :)

On the other hand in a longhish module you sometimes need std.array for other purposes, so you have imported it already.

"data.empty" is shorter, and it contains only two (psychological) chunks, while "data.length == 0" contains four. So empty makes the code simpler.

And empty doesn't break the syntax uniformity of UFCS chains :-)

Bye,
bearophile

Reply via email to