JanetDocsPlaygroundI'm feeling luckyGitHub sign in

array/fill



    cfunction
    src/core/array.c on line 152, column 1

    (array/fill arr &opt value)

    Replace all elements of an array with `value` (defaulting to nil) 
    without changing the length of the array. Returns the modified 
    array.


2 examplesSign in to add an example
Loading...
(def a @[1 2])           # => @[1 2]
(array/fill a @[3 4 5])  # => @[@[3 4 5] @[3 4 5]]
(array/concat (0 a) 6)   # => @[3 4 5 6]
a                        # => @[@[3 4 5 6] @[3 4 5 6]]
cellularmitosisPlayground
(def a @[1 2 3])
(array/fill a 17)   # => @[17 17 17]
(array/fill a "n")  # => @["b" "b" "b"]
(array/fill a)      # => @[nil nil nil]
a                   # => @[nil nil nil]
cellularmitosisPlayground