Difference between revisions of "Len"

From MiniScript Wiki
Jump to navigation Jump to search
(Created page with "<c>len</c> is a intrinsic function that returns the number of elements in a list, the number of characters in a string, or the number...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<c>len</c> is a [[:Category:Intrinsic Functions|intrinsic function]] that returns the number of elements in a [[list]], the number of characters in a [[string]], or the number of key/value pairs in a [[map]].
+
<c>len</c> is an [[:Category:Intrinsic Functions|intrinsic function]] that returns the number of elements in a [[list]], the number of characters in a [[string]], or the number of key/value pairs in a [[map]].
  
  
Line 18: Line 18:
 
== Example ==
 
== Example ==
  
<source lang="MiniScript">x = ["a", "b", "c"]
+
<ms>x = ["a", "b", "c"]
print x.len  // prints: 3</source>
+
print x.len  // prints: 3</ms>
  
 
[[Category:Intrinsic Functions]]
 
[[Category:Intrinsic Functions]]

Latest revision as of 20:56, 29 February 2020

len is an intrinsic function that returns the number of elements in a list, the number of characters in a string, or the number of key/value pairs in a map.


Arguments

Parameter Name Default Value Meaning
self sequence or map to calculate the length of

Usage Notes

len may be called either as a global method, passing the sequence or map as an argument; or as a member function (defined on list, string, and map) using dot syntax, with no arguments.

If called with something other than a list, string, or map, len returns null.

Example

x = ["a", "b", "c"]
print x.len   // prints: 3