txt: ## elems.md
  elems
  
  Combined from primary sources listed below.
  
  # [In Uni](#___top "go to top of document")[§](#(Uni)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Uni#method_elems)
  for **method elems**.
  
  ```raku
  method elems(Uni:D: --> Int:D)
  ```
  
  Returns the number of codepoints in the invocant.
  
  # [In List](#___top "go to top of document")[§](#(List)_routine_elems "direct link")
  
  See primary documentation
  [in context](/type/List#routine_elems)
  for **routine elems**.
  
  ```raku
  sub    elems($list --> Int:D)
  method elems(List:D: --> Int:D)
  ```
  
  Returns the number of elements in the list.
  
  ```raku
  say (1,2,3,4).elems; # OUTPUT: «4␤»
  ```
  
  # [In IterationBuffer](#___top "go to top of document")[§](#(IterationBuffer)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/IterationBuffer#method_elems)
  for **method elems**.
  
  ```raku
  method elems(IterationBuffer:D: --> Int:D)
  ```
  
  Returns the number of elements in the `IterationBuffer`.
  
  # [In role Baggy](#___top "go to top of document")[§](#(role_Baggy)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Baggy#method_elems)
  for **method elems**.
  
  ```raku
  method elems(Baggy:D: --> Int:D)
  ```
  
  Returns the number of elements in the `Baggy` object without taking the individual elements' weight into account.
  
  ```raku
  my $breakfast = bag <eggs spam spam spam>;
  say $breakfast.elems;                             # OUTPUT: «2␤»
  
  my $n = ("b" => 9.4, "b" => 2).MixHash;
  say $n.elems;                                     # OUTPUT: «1␤»
  ```
  
  # [In Capture](#___top "go to top of document")[§](#(Capture)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Capture#method_elems)
  for **method elems**.
  
  ```raku
  method elems(Capture:D: --> Int:D)
  ```
  
  Returns the number of positional elements in the `Capture`.
  
  ```raku
  my Capture $c = \(2, 3, 5, apples => (red => 2));
  say $c.elems; # OUTPUT: «3␤»
  ```
  
  # [In Seq](#___top "go to top of document")[§](#(Seq)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Seq#method_elems)
  for **method elems**.
  
  ```raku
  method elems(Seq:D:)
  ```
  
  Returns the number of values in the sequence. If this number cannot be predicted, the `Seq` is cached and evaluated till the end.
  
  Because an infinite sequence cannot be evaluated till the end, such a sequence *should* be declared lazy. Calling `.elems` on a lazy `Seq` [fail](/routine/fail)s with [`X::Cannot::Lazy`](/type/X/Cannot/Lazy).
  
  # [In Range](#___top "go to top of document")[§](#(Range)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Range#method_elems)
  for **method elems**.
  
  ```raku
  method elems(Range:D: --> Numeric:D)
  ```
  
  Returns the number of elements in the range, e.g. when being iterated over, or when used as a [`List`](/type/List). Returns 0 if the start point is larger than the end point, including when the start point was specified as `∞`. Fails when the Range is lazy, including when the end point was specified as `∞` or either end point was specified as `*`.
  
  ```raku
  say (1..5).elems;                                 # OUTPUT: «5␤»
  say (1^..^5).elems;                               # OUTPUT: «3␤»
  ```
  
  # [In Map](#___top "go to top of document")[§](#(Map)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Map#method_elems)
  for **method elems**.
  
  ```raku
  method elems(Map:D: --> Int:D)
  ```
  
  Returns the number of pairs stored in the Map.
  
  ```raku
  my %map = Map.new('a', 1, 'b', 2);
  say %map.elems; # OUTPUT: «2␤»
  ```
  
  # [In Subscripts](#___top "go to top of document")[§](#(Subscripts)_method_elems "direct link")
  
  See primary documentation
  [in context](/language/subscripts#method_elems)
  for **method elems**.
  
  ```raku
  multi method elems(::?CLASS:D:)
  ```
  
  Expected to return a number indicating how many subscriptable elements there are in the object. May be called by users directly, and is also called by [`postcircumfix [ ]`](/language/operators#postcircumfix_[_]) when indexing elements from the end, as in `@foo[*-1]`.
  
  If not implemented, your type will inherit the default implementation from [`Any`](/type/Any) that always returns `1` for defined invocants - which is most likely not what you want. So if the number of elements cannot be known for your positional type, add an implementation that [fail](/routine/fail)s or [die](/routine/die)s, to avoid silently doing the wrong thing.
  
  # [In Array](#___top "go to top of document")[§](#(Array)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Array#method_elems)
  for **method elems**.
  
  ```raku
  method elems(Array:D: --> Int:D)
  ```
  
  Returns the number of elements in the invocant. Throws [`X::Cannot::Lazy`](/type/X/Cannot/Lazy) exception if the invocant [is lazy](/routine/is-lazy). For shaped arrays, returns the outer dimension; see [shape](/routine/shape) if you need information for all dimensions.
  
  ```raku
  say [<foo bar ber>] .elems; # OUTPUT: «3␤»
  say (my @a[42;3;70]).elems; # OUTPUT: «42␤»
  
  try [-∞...∞].elems;
  say $!.^name;               # OUTPUT: «X::Cannot::Lazy␤»
  ```
  
  # [In role Positional](#___top "go to top of document")[§](#(role_Positional)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Positional#method_elems)
  for **method elems**.
  
  ```raku
  method elems()
  ```
  
  Should return the number of available elements in the instantiated object.
  
  # [In Any](#___top "go to top of document")[§](#(Any)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Any#method_elems)
  for **method elems**.
  
  ```raku
  multi method elems(Any:U: --> 1)
  multi method elems(Any:D:)
  ```
  
  Interprets the invocant as a list, and returns the number of elements in the list.
  
  ```raku
  say 42.elems;                   # OUTPUT: «1␤»
  say <a b c>.elems;              # OUTPUT: «3␤»
  say Whatever.elems ;            # OUTPUT: «1␤»
  ```
  
  It will also return 1 for classes.
  
  # [In role Blob](#___top "go to top of document")[§](#(role_Blob)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Blob#method_elems)
  for **method elems**.
  
  ```raku
  multi method elems(Blob:D:)
  ```
  
  Returns the number of elements of the buffer.
  
  ```raku
  my $blob = Blob.new([1, 2, 3]);
  say $blob.elems; # OUTPUT: «3␤»
  ```
  
  # [In Metamodel::EnumHOW](#___top "go to top of document")[§](#(Metamodel::EnumHOW)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Metamodel/EnumHOW#method_elems)
  for **method elems**.
  
  ```raku
  method elems($obj)
  ```
  
  Returns the number of values.
  
  ```raku
  enum Numbers <10 20>;
  say Numbers.^elems;                         # OUTPUT: 2
  ```
  
  # [In role Setty](#___top "go to top of document")[§](#(role_Setty)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Setty#method_elems)
  for **method elems**.
  
  ```raku
  method elems(Setty:D: --> Int)
  ```
  
  The number of elements of the set.
  
  # [In Supply](#___top "go to top of document")[§](#(Supply)_method_elems "direct link")
  
  See primary documentation
  [in context](/type/Supply#method_elems)
  for **method elems**.
  
  ```raku
  method elems(Supply:D: $seconds? --> Supply:D)
  ```
  
  Creates a new supply in which changes to the number of values seen are emitted. It optionally also takes an interval (in seconds) if you only want to be updated every so many seconds.
  