clojure.core/struct¶
Returns a new structmap instance with the keys of the structure-basis. vals must be supplied for basis keys in order - where values are not supplied they will default to nil.
Examples¶
Note by Dimagog¶
Structs are becoming obsolete. Use records instead. See defrecord.
Note by metasoarous¶
In general, records should be preferred over structs. However, structs aren't entirely obsolete.
They can still be useful when you need/want to create record-like objects dynamically; That is, when you don't know the field names at compile time. A typical example of this might be loading rows from a CSV (as semantic-csv does). The advantage in this case over using regular maps is significantly improved performance creating and using these objects.
See also¶
Content from the matching ClojureDocs page, with authors credited on each contribution.