Skip to content

Commit

Permalink
Correct use of @pack! (#124)
Browse files Browse the repository at this point in the history
I've changed the example on the @pack section so that the macros are applied to a mutable structure
  • Loading branch information
joaogoliveira1 authored May 23, 2020
1 parent 7ed74d0 commit 77575a3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docs/src/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,17 @@ The preferred to do this is using the `@unpack` and
and also work with non-`@with_kw` stucts, named-tuples, modules, and
dictionaries.
Here one example is given, for more see the README of
UnPack. Continuing with the `Para` struct defined above:
UnPack. Define a mutable struct `MPara`:
```julia
function fn2(var, pa::Para)
@with_kw mutable struct MPara{R<:Real}
a::R = 5
b::R
c::R = a+b
end
pa = MPara(b=7)

function fn2(var, pa::MPara)
@unpack a, b = pa # equivalent to: a,b = pa.a,pa.b
out = var + a + b
b = 77
Expand Down

0 comments on commit 77575a3

Please sign in to comment.