The add routine

Combined from primary sources listed below.

In class IO::Path ( Type/IO/Path )§

See primary docmentation in context for method add.

method add§

method add(IO::Path:D: Str() $what --> IO::Path:D)

Concatenates a path fragment to the invocant and returns the resultant IO::Path. If adding ../ to paths that end with a file, you may need to call resolve for the resultant path to be accessible by other IO::Path methods like dir or open. See also sibling and parent.

"foo/bar".IO.mkdir;
"foo/bar".IO.add("meow")    .resolve.relative.say# OUTPUT: «foo/bar/meow␤»
"foo/bar".IO.add("/meow")   .resolve.relative.say# OUTPUT: «foo/bar/meow␤»
"foo/bar".IO.add("meow.txt").resolve.relative.say# OUTPUT: «foo/bar/meow.txt␤»
"foo/bar".IO.add("../meow") .resolve.relative.say# OUTPUT: «foo/meow␤»
"foo/bar".IO.add("../../")  .resolve.relative.say# OUTPUT: «.␤»

method add(IO::Path:D: *@parts --> IO::Path:D)

As of release 2021.07 of the Rakudo compiler, it is also possible to specify multiple parts to be added to a path.

"foo".IO.add(<bar baz>).resolve.relative.say;      # OUTPUT: «foo/bar/baz␤»

In role Metamodel::MethodContainer ( Type/Metamodel/MethodContainer )§

See primary docmentation in context for method add.

method add_method§

method add_method($obj, $name, $code)

Adds a method to the metaclass, to be called with name $name. This should only be done before a type is composed.

In role Metamodel::PrivateMethodContainer ( Type/Metamodel/PrivateMethodContainer )§

See primary docmentation in context for method add.

method add_private_method§

method add_private_method($obj, $name, $code)

Adds a private method $code with name $name.

In role Metamodel::RoleContainer ( Type/Metamodel/RoleContainer )§

See primary docmentation in context for method add.

method add_role§

method add_role($obj, Mu $role)

Adds the $role to the list of roles to be composed.

In class RakuAST::Doc::Block ( Type/RakuAST/Doc/Block )§

See primary docmentation in context for method add.

method add-paragraph§

$block.add-paragraph("baz\n\n");

Add a paragraph: should be a string, or a RakuAST::Doc::Paragraph object.

In class RakuAST::Doc::Block ( Type/RakuAST/Doc/Block )§

See primary docmentation in context for method add.

method add-config§

$block.add-config(
  'allow',
  RakuAST::QuotedString.new(
    processors => <words val>,
    segments   => (
      RakuAST::StrLiteral.new("B C"),
    )
  )
);

Takes a key and a value to add to the configuration. Value is expected to be either a string or a RakuAST object.

In class RakuAST::Doc::DeclaratorTarget ( Type/RakuAST/Doc/DeclaratorTarget )§

See primary docmentation in context for method add.

method add-trailing§

$target.add-trailing("additional");

Add a line to the trailing documentation. Creates a RakuAST::Doc::Declarator object and sets it in the .WHY if there wasn't one already.

In class RakuAST::Doc::DeclaratorTarget ( Type/RakuAST/Doc/DeclaratorTarget )§

See primary docmentation in context for method add.

method add-leading§

$target.add-leading("additional");

Add a line to the leading documentation. Creates a RakuAST::Doc::Declarator object and sets it in the .WHY if there wasn't one already.

In class RakuAST::Doc::Markup ( Type/RakuAST/Doc/Markup )§

See primary docmentation in context for method add.

method add-atom§

$markup.add-atom( ("foo",) );

Add an atom to the atoms of the object. Values are expected to be either a string, or a RakuAST::Doc::Markup object.

In class RakuAST::Doc::Markup ( Type/RakuAST/Doc/Markup )§

See primary docmentation in context for method add.

method add-meta§

$markup.add-meta( ("bar",) );

Add an item to the meta-information of the object. Values are expected to be either a string, or a RakuAST::Doc::Markup object.

In role Metamodel::Stashing ( Type/Metamodel/Stashing )§

See primary docmentation in context for method add.

method add_stash§

method add_stash($type_obj)

Creates and sets a stash for a type, returning $type_obj.

This method is typically called as the last step of creating a new type. For example, this is how it would be used in a minimal HOW that only supports naming and stashing:

class WithStashHOW
    does Metamodel::Naming
    does Metamodel::Stashing
{
    method new_type(WithStashHOW:_: Str:D :$name--> Mu) {
        my WithStashHOW:D $meta := self.new;
        my Mu             $type := Metamodel::Primitives.create_type: $meta, 'Uninstantiable';
        $meta.set_name: $type, $name;
        self.add_stash: $type
    }
}

my Mu constant WithStash = WithStashHOW.new_type: :name<WithStash>;
say WithStash.WHO# OUTPUT: «WithStash␤»

In class RakuAST::Doc::Declarator ( Type/RakuAST/Doc/Declarator )§

See primary docmentation in context for method add.

method add-leading§

$declarator.add-leading("additional");

Add a line to the leading documentation.

In class RakuAST::Doc::Declarator ( Type/RakuAST/Doc/Declarator )§

See primary docmentation in context for method add.

method add-trailing§

$declarator.add-trailing("additional");

Add a line to the trailing documentation.

In class Metamodel::ClassHOW ( Type/Metamodel/ClassHOW )§

See primary docmentation in context for method add.

method add_fallback§

method add_fallback($obj, $condition, $calculator)

Installs a method fallback, that is, add a way to call methods that weren't statically added.

Both $condition and $calculator must be callables that receive the invocant and the method name once a method is called that can't be found in the method cache.

If $condition returns a true value, $calculator is called with the same arguments, and must return the code object to be invoked as the method, and is added to the method cache.

If $condition returns a false value, the next fallback (if any) is tried, and if none matches, an exception of type X::Method::NotFound is thrown.

User-facing code (that is, code not dabbling with metaclasses) should use method FALLBACK instead.

In class BagHash ( Type/BagHash )§

See primary docmentation in context for method add.

method add§

method add(BagHash: \to-add, *%_ --> Nil)

When to-add is a single item, add inserts it into the BagHash or, if it was already present, increases its weight by 1. When to-add is a List, Array, Seq, or any other type that does the Iterator Role, add inserts each element of the Iterator into the SetHash or increments the weight of each element by 1.

Note: Added in version 2020.02.

In class Metamodel::EnumHOW ( Type/Metamodel/EnumHOW )§

See primary docmentation in context for method add.

method add_enum_value§

method add_enum_value($obj, $value)

Adds a value to this enum. $value should be an instance of the enum itself, as type Enumeration.

In class Metamodel::EnumHOW ( Type/Metamodel/EnumHOW )§

See primary docmentation in context for method add.

method add_parent§

method add_parent($obj, $parent)

Sets the base type of an enum. This can only be used if no base type was passed to .new_type.

In role Metamodel::Trusting ( Type/Metamodel/Trusting )§

See primary docmentation in context for method add.

method add_trustee§

method add_trustee($type, Mu $trustee)

Trust $trustee.

class A {
    BEGIN A.^add_trustee(B);
    # same as 'trusts B';
}

In class RakuAST::Doc::Paragraph ( Type/RakuAST/Doc/Paragraph )§

See primary docmentation in context for method add.

method add-atom§

$paragraph.add-atom("baz\n");

Add an atom: should be a string, or a RakuAST::Doc::Markup object.

In role Metamodel::MultipleInheritance ( Type/Metamodel/MultipleInheritance )§

See primary docmentation in context for method add.

method add_parent§

method add_parent($obj, $parent, :$hides)

Adds $parent as a parent type. If $hides is set to a true value, the parent type is added as a hidden parent.

$parent must be a fully composed typed. Otherwise an exception of type X::Inheritance::NotComposed is thrown.

In role Metamodel::AttributeContainer ( Type/Metamodel/AttributeContainer )§

See primary docmentation in context for method add.

method add_attribute§

method add_attribute($obj, $attribute)

Adds an attribute. $attribute must be an object that supports the methods name, type and package, which are called without arguments. It can for example be of type Attribute.