title: "ERROR: LoadError: BoundsError: attempt to access 0-element Array{Candidate,1} at index [1]" when trying to fill the empty array of a composite type
body: <p>I get an error when trying to populate an empty array with input from a user.</p>
  <pre><code>const max = 9 # a maximal number of candidates
  
  # Let us define a composite type for the candidates in our elections
  mutable struct Candidate
      name::String
      votes::Int8
   end
   
   
  candidates = Candidate[]
  
  i = 1
  
  while i &lt; max
   println(&quot;Name of the candidate: ?&quot;)
   candidates[i].name = readline();
   println(&quot;Votes on him: ?&quot;)
   candidates[i].votes = parse(Int8, readline(), base=10);
   println(&quot;Thank you, let us move to the next candidate.&quot;)
   global i = i +1    
   end
  </code></pre>
  <p>After (&quot;Name of the candidate: ?&quot;) being displayed, I get the following error:</p>
  <pre><code>ERROR: LoadError: BoundsError: attempt to access 0-element Array{Candidate,1} at index [1]
  Stacktrace:
   [1] getindex(::Array{Candidate,1}, ::Int64) at ./array.jl:731
   [2] top-level scope at /home/jerzy/ComputerScience/SoftwareDevelopment/MySoftware/MyJulia/plurality.jl:18 [inlined]
   [3] top-level scope at ./none:0
   [4] include at ./boot.jl:317 [inlined]
   [5] include_relative(::Module, ::String) at ./loading.jl:1044
   [6] include(::Module, ::String) at ./sysimg.jl:29
   [7] exec_options(::Base.JLOptions) at ./client.jl:266
   [8] _start() at ./client.jl:425
  in expression starting at /home/jerzy/ComputerScience/SoftwareDevelopment/MySoftware/MyJulia/plurality.jl:16
  </code></pre>
  <p>Alternatively, using</p>
  <pre><code>candidates = Array{Candidate}(undef, 0)
  </code></pre>
  <p>instead of</p>
  <pre><code>candidates = Candidate[]
  </code></pre>
  <p>results in:</p>
  <pre><code>ERROR: LoadError: UndefRefError: access to undefined reference
  </code></pre>
  <p>Apologies for being such a newbie. I relied on <a href="https://en.wikibooks.org/wiki/Introducing_Julia/Arrays_and_tuples#Creating_simple_arrays" rel="noreferrer">what I read in this wikibook</a>. Would you refer me to some more reading?</p>