Logtalk built-in method: assertz/1

contents > reference manual > built-in methods

## `assertz/1`

#### Description

>     assertz(Clause)
>     assertz((Head:-Body))

> Asserts a clause as the last one for an object's dynamic predicate. If the predicate is not already declared, then a dynamic predicate declaration is added to the object.

#### Template and modes

>     assertz(+clause)

#### Errors

> Clause is a variable:
>   `instantiation_error`
> Head is a variable:
>   `instantiation_error`
> Head is a neither a variable nor a callable term:
>   `type_error(callable, Head)`
> Body cannot be converted to a goal:
>   `type_error(callable, Body)`
> The predicate indicator of Head is that of a private predicate:
>   `permission_error(modify, private_predicate, Head)`
> The predicate indicator of Head is that of a protected predicate:
>   `permission_error(modify, protected_predicate, Head)`
> The predicate indicator of Head is that of a static predicate:
>   `permission_error(modify, static_predicate, Head)`

#### Examples

> To assert a clause as the last one for any dynamic predicate in this:
>   `assertz(Clause)`
> To assert a clause as the last one for any public or protected dynamic predicate in self:
>   `::assertz(Clause)`
> To assert a clause as the last one for any public dynamic predicate in an object:
>   `Object::assertz(Clause)`

previous | glossary | next
Copyright © Paulo Moura — Logtalk.org