Collection length


I am trying to get the lenght of a collection.

I have tried length(collection) but it doesn’t output how many items are in the collection

It won’t. Collections are just key value pairs and don’t have a length. Arrays and strings have lengths.

Why do need a collection length pray tell?

Hi Alex, thanks for the reply!

I need as form of validation.

I want certain strings to display, only if the collection length is less than a specified number.

if(collection_lenght < 3; string; nothing)

Actually if you do a a length(keys(collection)) that should do it.

Also if you ever want to do array functions on a collection (ie Object) use toArray(collection)

1 Like

The length(keys(collection)) really worked! Many thanks! :grin:

1 Like