Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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

Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
16,126
Link Karma
957
Comment Karma
15,156
Profile updated: 1 week ago
Posts updated: 10 months ago

Subreddit

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