The following is a snippet of a method that accepts an array of strings or a blank array([]):
# @param [Array<String>] bar
def foo(bar)
if bar.empty?
# Do this
else
# Do that
end
end
I feel like this @param type is a bit misleading.
Is there a better way to document the blank array use case explicitly?
In your case if you know that the expected argument is an array of strings, then
[Array<String>]is enough (IMO) for@param. What might change is the return value whether the argument is empty or not, for that you can do as it's mentioned in the docs:For your example: