-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requests
Description
I find the syntax for creating uninitialized arrays a bit verbose, while there are nice and short options for almost all other common cases of creating arrays:
# compare to
Float64[1, 2, 3, 4, 5]
zeros(Float64, 10)
ones(Float64, 10)
fill(1.0, 10)But for uninitialized arrays you always have to use curly bracket syntax if I'm correct:
v = Vector{Float64}(undef, 10)How about one of these two alternatives, which both seem to be available:
v = Float64[undef, 10]
arr = Int32[undef, 3, 4, 5]
# or
v = undef(Float64, 10)
arr = undef(Int32, 3, 4, 5)The second one is actually easy to get via:
(::UndefInitializer)(T::Type, dims::Vararg{Int}) = Array{T}(undef, dims...)jakobnissen, lbenet, nathanrboyer, schneiderfelipe, jakpid and 4 more
Metadata
Metadata
Assignees
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requests