JanetDocsPlaygroundI'm feeling luckyGitHub sign in

array



    cfunction
    src/core/corelib.c on line 404, column 1

    (array & items)

    Create a new array that contains items. Returns the new array.


3 examplesSign in to add an example
Loading...
(def arr (array :a [:b :c] :d))
# => @[:a (:b :c) :d]
(0 arr)
# => :a
(1 arr)
# => (:b :c)

# out-of-bounds access causes an error
(try
  (3 arr)
  ([err] err))
# => "expected integer key for array in range [0, 3), got 3"

# you may use `get` to avoid the error
(get arr 3)
# => nil
AndriamanitraPlayground
(array 1 2.3 :a "foo" true nil [] {} (fn []))
# => @[1 2.3 :a "foo" true nil () {} <function 0x7FB2A3F02170>]
cellularmitosisPlayground
@[1 2 3]                 # -> @[1 2 3]
(array 1 2 3)            # -> @[1 2 3]
(array (splice [1 2 3])  # -> @[1 2 3]
(array ;[1 2 3])         # -> @[1 2 3]
cellularmitosisPlayground