Skip to content

clojure.core/import

View this page on ClojureDocs

Type: macro Added: Clojure 1.0 Examples: 5 Runnable: 2
([& import-symbols-or-lists])

import-list => (package-symbol class-name-symbols*)

For each name in class-name-symbols, adds a mapping from name to the class named by package.name to the current namespace. Use :import in the ns macro in preference to calling this directly.

Examples

by nipra on . May have evaluation errors.
by dale on
by klauern on
by phreed on . May have evaluation errors.
by ooooak on . May have evaluation errors.

Note by gstamp

Good description of use/require/import here:

http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns

Note by TimMc

import will also accept vectors instead of lists, but I would discourage folks from doing so:

  • It's undocumented.
  • Lists and vectors have different meanings for require, so there's precedent for making a distinction.
  • Lists have a distinguished first element, and so they indent more meaningfully here. :-P

Note by YizhePKU

You don't need to use import if you fully qualify the class name, e.g. (java.util.Date.).

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.