Locating Scala Array deep documentation?

2019-07-10 00:35发布

问题:

SO answer by Jerry includes this use of deep:

println(k.deep)

Works as described:

scala> println(Array(10, 20, 30, 40).deep)
Array(10, 20, 30, 40)

I am looking for documentation on deep for an Array. I go to Scala Standard Library 2.13.0 Array and do a search of the page for deepand get no matches.

How is this the incorrect sequence?

回答1:

It seems it has been removed from Scala 2.13 according to https://github.com/scala/bug/issues/10985:

It's a hacky ugly testing utility to print values in (nested) arrays. If you feel strongly about it, we can add it deprecated.

You can still find it in 2.12 docs and in 2.12 branch:

  /** Creates a possible nested `IndexedSeq` which consists of all the elements
   *  of this array. If the elements are arrays themselves, the `deep` transformation
   *  is applied recursively to them. The `stringPrefix` of the `IndexedSeq` is
   *  "Array", hence the `IndexedSeq` prints like an array with all its
   *  elements shown, and the same recursively for any subarrays.
   *
   *  Example:
   *  {{{
   *  Array(Array(1, 2), Array(3, 4)).deep.toString
   *  }}}
   *  prints: `Array(Array(1, 2), Array(3, 4))`
   *
   *  @return    An possibly nested indexed sequence of consisting of all the elements of the array.
   */
  def deep: scala.collection.IndexedSeq[Any]