module Novika::IDict

Overview

Novika dictionary protocol. Objects or values that want to be Block dictionaries can implement this protocol to make that possible.

Direct including types

Defined in:

novika/dict.cr

Instance Method Summary

Instance Method Detail

abstract def clear #

Removes all entries in this dictionary.


abstract def copy : IDict #

Returns a shallow copy of this dictionary.


abstract def count : Int32 #

Returns the amount of entries in this dictionary.


abstract def del(name : Form) #

Deletes the entry corresponding to name form in this dictionary if it exists. Otherwise, does nothing.


abstract def each(& : Form, Form -> ) #

Yields key, value forms in this dictionary.


def empty? : Bool #

Returns whether this dictionary currently stores no entries.


abstract def get(name : Form, & : Form -> Entry | Nil) : Entry | Nil #

Returns the entry corresponding to name form in this dictionary, or yields with name and returns the block result.


abstract def has?(name : Form) : Bool #

Returns whether this dictionary has an entry corresponding to name form.


abstract def import!(donor : IDict) #

Imports entries from donor dictionary into this dictionary.

Entries whose names are preceded by one or more _ are not imported (they are considered private).


abstract def set(name : Form, entry : Entry) : Entry #

Assigns name form to entry in this dictionary.


abstract def to_dict : Dict #

Converts this dictionary to the standard Dict implementation (used in e.g. serialization).