title: Why does Array.fill take an implicit scala.reflect.ClassManifest?
body: <p>So I'm playing with writing a <a href="http://www.battlecode.org/contestants/releases/" rel="nofollow">battlecode</a> player in Scala.  In battlecode certain classes are disallowed and there is a runtime exception if you ever try to access them.  When I use the <a href="http://www.scala-lang.org/api/current/index.html#scala.Array%24" rel="nofollow">Array.fill</a> function I get a message from the battlecode server saying <code>[java] Illegal class: scala/reflect/Manifest$</code>.  This is the offending line:</p>
  
  <pre><code>val g_score = Array.fill[Int](rc.getMapWidth(), rc.getMapHeight())(0)
  </code></pre>
  
  <p>The method takes an implicit <code>ClassManifest</code> argument which has the following documentation:</p>
  
  <pre><code>A ClassManifest[T] is an opaque descriptor for type T. It is used by the compiler
  to preserve information necessary for instantiating Arrays in those cases where
  the element type is unknown at compile time.
  </code></pre>
  
  <p>But I do know the type of the array elements at compile time, as shown above I explicitly state that they will be <code>Int</code>.  Is there a way to avoid this?  To workaround I've written my own version of <code>Array.fill</code>.  This seems like a hack.  As an aside, does Scala have real 2D arrays?  <code>Array.fill</code> seems to return an <code>Array[Array[T]]</code> which is the only way I found to write my own.  This also seems inelegant.</p>
  
  <p>Edit:  Using Scala 2.9.1</p>