Skip to content

Commit

Permalink
Merge pull request #2447 from nickanderson/CFE-3636/master
Browse files Browse the repository at this point in the history
CFE-3636: Switched to live examples from core for body inheritance (master)
  • Loading branch information
nickanderson committed May 4, 2021
2 parents 9512e31 + 464b272 commit dda32e6
Showing 1 changed file with 3 additions and 38 deletions.
41 changes: 3 additions & 38 deletions reference/promise-types.markdown
Expand Up @@ -1242,46 +1242,11 @@ type as a function call. For a detailed description, see

**Allowed input range:** (arbitrary body invocation)

**Example:**

A simple example first, which has no parameters:
**Examples:**

```cf3
body TYPE parent
{
atribute1 => 100;
atribute2 => { "a" };
atribute3 => 75;
}
body TYPE child
{
inherit_from => parent; # same as parent()
atribute3 => 300; # overwrites parent's attribute3
# has atribute1 => 100;
# has atribute2 => { "a" };
}
```
[%CFEngine_include_example(inherit_from.cf)%]

Now with parameters. The child calls the parent as a function call.
Note that the child's parameters can be passed up to the parent.

```cf3
body TYPE parent(a1, a2)
{
atribute1 => $(a1);
atribute2 => { $(a2) };
atribute3 => 75;
}
body TYPE child(aaa)
{
inherit_from => parent(5, $(aaa));
atribute3 => 300; # overwrites parent's attribute3
# has atribute1 => 5;
# has atribute2 => { $(aaa) };
}
```
[%CFEngine_include_example(inherit_from_classes.cf)%]

**History:** Was introduced in 3.8.0.

Expand Down

0 comments on commit dda32e6

Please sign in to comment.