# Docstring: how to format returns

**URL:** https://discourse.julialang.org/t/docstring-how-to-format-returns/95850
**Category:** General Usage
**Created:** [March 10, 2023, 9:29am UTC](https://discourse.julialang.org/t/docstring-how-to-format-returns/95850 "2023-03-10T09:29:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![AdamWysokinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adamwysokinski/32/206422_2.png) [@AdamWysokinski](https://discourse.julialang.org/u/AdamWysokinski)
#### Post date: [March 10, 2023, 9:29am UTC](https://discourse.julialang.org/t/docstring-how-to-format-returns/95850/1 "2023-03-10T09:29:42Z")

</div>

Hi,  
I wonder if there is any standardized way of reporting function return in its docstring for something like this:

```julia
"""
    test(x)

Test whether `x` is greater than 0.

# Arguments

- `x::Int64`: the number to test

# Returns

- `::Bool`: true, if `x` is greater than zero
"""
function test(x::Int64)
    return x > 0
end

```

Since the function returns result and not a variable value, how should the returns look like?  
`- `::Bool`: true, if `x` is greater than zero`  
or  
`- `Bool`: true, if `x` is greater than zero`  
or  
`- `test::Bool`: true, if `x` is greater than zero` - this seems to make most sense to me  
?  
Adam

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [March 10, 2023, 11:02am UTC](https://discourse.julialang.org/t/docstring-how-to-format-returns/95850/2 "2023-03-10T11:02:07Z")

</div>

This way:

```julia
"""
    test(x) -> Bool

Test whether `x` is greater than 0.
"""
test(x) = ...

```

is quite common, at least in Julia base documentation.

---

<div class="post-metadata">

### Author: ![AdamWysokinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adamwysokinski/32/206422_2.png) [@AdamWysokinski](https://discourse.julialang.org/u/AdamWysokinski)
#### Post date: [March 10, 2023, 1:15pm UTC](https://discourse.julialang.org/t/docstring-how-to-format-returns/95850/3 "2023-03-10T13:15:36Z")

</div>

Thanks!

---

<div class="post-metadata">

### Author: ![AdamWysokinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adamwysokinski/32/206422_2.png) [@AdamWysokinski](https://discourse.julialang.org/u/AdamWysokinski)
#### Post date: [March 11, 2023, 8:36am UTC](https://discourse.julialang.org/t/docstring-how-to-format-returns/95850/4 "2023-03-11T08:36:50Z")

</div>

I’ve been thinking about this solution. It’s simple and elegant, but what about functions returning more complex outputs, e.g. a named tuple:

```julia
function test(x::Vector{Int})
    return (x1=x[1], x2=x[2])
end

```
