function D = createArray(dims, F)
%createArray  Create a codistributed array of a specified size and class
%   X = createArray(..., codistributed)
%   X = createArray(..., Like = T)
%   X = createArray(..., FillValue = F)
%   X = createArray(..., CLASSNAME, FillValue = F)
%   X = createArray(..., Like = T, FillValue = F)
%   
%   See also createArray, CODISTRIBUTED.


%   Copyright 2023-2024 The MathWorks, Inc.

% Static build method.
if nargin<2
    % Default to full real double zero.
    F = 0;
elseif ~isscalar(F)
    error(message("MATLAB:createArray:invalidFillValue"));
end

% CreateArray design is that we construct then assign.
T = codistributed.empty;
T = subsasgn(T,substruct("()",{1}), F); % This will error if the conversion is not valid.

% Now that the FillValue is codistributed we can just use the "like" version.
D = createArrayLike(T, dims, T);

end
