This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
2
Lua doc strings - how to document parameter that accepts different types
Post Body
I've been looking through some original source code docs and as much lua documentation as I can, but I was wondering on the best practice for documenting an optional parameter type. By optional parameter type I mean that the function handles the different types internally, but I want to write a docstring to accurately document this. My apologies for the confusing explanation, an example may make more sense.
--- Do foo things to bar
-- @param bar type1 w/ description
-- OR type2 w/ description
function foo(bar):
if type(bar) == number:
do_thing_a(bar)
elseif type(bar) == table:
do_thing_b(bar)
else
do_thing_c(bar)
end
end
Many thanks
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/lua/comment...