Skip to content

Commit 306a0bd

Browse files
committed
add example with nameof(@__FUNCTION__)
1 parent da27508 commit 306a0bd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

base/runtime_internals.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,16 @@ julia> factorial = n -> n <= 1 ? 1 : n * (@__FUNCTION__)(n - 1);
219219
julia> factorial(5)
220220
120
221221
```
222+
223+
`@__FUNCTION__` can also be combined with `nameof` to get the symbol of the
224+
enclosing function:
225+
226+
```jldoctest
227+
julia> bar() = nameof(@__FUNCTION__);
228+
229+
julia> bar()
230+
:bar
231+
```
222232
"""
223233
macro __FUNCTION__()
224234
quote

0 commit comments

Comments
 (0)