首页 > 解决方案 > 查找 Scala Array 深层文档?

问题描述

杰里的回答包括以下用途deep

println(k.deep)

按描述工作:

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

我正在寻找deep有关Array. 我转到Scala Standard Library 2.13.0 Array并搜索页面deep并没有匹配项。

Scala Array w 搜索“深”

这是错误的顺序怎么办?

标签: scaladocumentation

解决方案


根据https://github.com/scala/bug/issues/10985,它似乎已从 Scala 2.13 中删除:

这是一个在(嵌套)数组中打印值的 hacky 丑陋测试实用程序。如果您对此感觉强烈,我们可以将其添加为已弃用。

您仍然可以在2.12 文档2.12 分支中找到它:

  /** 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]

推荐阅读