1

Let's say I have the following function:

@param foo [Array<String>]
def recursive_split(foo)
  bar = []
  foo.each do |elem|
    bar.append(elem.split(''))
  end
  bar
end

How do I document with the yard @return tag that my return value is an array of arrays of strings ? Is @return [Array<Array<String>>] the right way to do it ?

1 Answer 1

4

The docs aren't that specific but types specifiers are recursive so the X in Array<X> can be any list of valid types so these:

Array<String>
Array<String, Symbol>
Array<Array<String, Symbol, #m>>
Array<String, Array<#m>>
...

are all valid.

The online type parser is probably the easiest way to check. That says that Array<Array<String>> is:

an Array of (an Array of (Strings))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.