Skip to content

How to document a fixed size array when arguments can be multi typed? #1579

Answered by lsegal
aaronmallen asked this question in Q&A
Discussion options

You must be logged in to vote

YARD doesn't really contain a type system, although there are some intuitive conventions used (and parsed by the yard type parser), but these are not enforced anywhere. Because of this, you can ultimately use whatever syntax you prefer, to communicate the type.

One thing you might consider is splitting this into two types-- specifically:

# @param foo [Array(Integer, String), Array(Integer, Symbol)] ...

This would be supported by the type parser:

an Array containing (an Integer followed by a String);
an Array containing (an Integer followed by a Symbol)

You could also use the | character commonly used in other type systems to specify this as Array(Integer, String | Symbol), which I think …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aaronmallen
Comment options

Answer selected by aaronmallen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1578 on September 05, 2024 08:05.