4

除了指定它输出的内容之外,我对这个函数没有任何用处。如果 Yard 没有找到描述,它会使用 的内容@return。有什么办法可以防止这种情况发生吗?我想避免像您在下面的示例中看到的那样愚蠢的重复。

##
# @return [Array<Hash>]
#
#   an array of hashes. Example output:
#
#     [
#       {:name=>"FORNEBU", :municipality=>"BÆRUM", :county=>"AKERSHUS"},
#       {:name=>"FORSAND", :municipality=>"FORSAND", :county=>"ROGALAND"}
#     ]
#

截屏

4

1 回答 1

1

你可以使用@example 标签

##
# @return [Array<Hash>]
# @example
#   an array of hashes. Example output:
#
#     [
#       {:name=>"FORNEBU", :municipality=>"BÆRUM", :county=>"AKERSHUS"},
#       {:name=>"FORSAND", :municipality=>"FORSAND", :county=>"ROGALAND"}
#     ]
#

输出码输出

方法描述如下:

#method_name(args) ⇒ Array<Hash>
于 2018-04-28T17:09:49.470 回答