length( item )

Returns the length of the supplied item. The function can be applied to various different datatypes, as illustrated below:

lists
number of items in the list
:-) var list = newList( 1, 2, 3, 4 );
There are 0 results
:-) list.length;
There is 1 result
4
          
maps
number of key-value pairs in this map
:-) var map = newMap( "hello" ==> "there", "whats" ==> "that" );
There are 0 results
:-) map.length;
There is 1 result
2
          
strings
number of characters in the string
:-) "A string".length;
There is 1 result
8
          
maplet
Always 2
:-) var maplet = newMaplet( "key", "value" );
There are 0 results
:-) maplet.length;
There is 1 result
2
          
XML
number of children
:-) var xml = <element>"hello", 2, <blah><child/></blah>, 72, "what"</element>
There are 0 results
:-) xml.length;
There is 1 result
5
          

It's also worth noting that MillScript can also operate with any other Java objects and the length function can be applied to them. The only clause is that the objects must implement one of the following interfaces: Collection, List, Map or Map.Entry