[ Non-logical Variables, Arrays, Bags, Shelves and Stores | Reference Manual | Alphabetic Index ]

# bag_erase(+BagHandle)

Erase the contents of a bag

BagHandle
  A bag handle

## Description

This explicitly erases the contents of a previously created bag object and frees the associated memory. After erasing, the bag is in the same state as immediately after creation, and can be filled with new contents.

### Modes and Determinism

- bag_erase(+) is det

### Exceptions

(4) instantiation fault
  BagHandle is not instantiated
(5) type error
  BagHandle is not a bag
(40) stale object handle
  BagHandle refers to an already destroyed bag

## Examples

        ?- bag_create(B), bag_enter(B, one), bag_erase(B), bag_enter(B, two), bag_retrieve(B, L).
        B = $&(bag,"371bnb")
        L = [two]
        Yes (0.00s cpu)

## See Also

bag_create / 1, bag_abolish / 1, bag_enter / 2, bag_count / 2, bag_retrieve / 2, bag_dissolve / 2