Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Struct variables explicit setting

$
0
0

Hi!
I know how to do this:

struct a
       a1
       a2
       a3
end
b=a(1,2,3)

I was wondering if there’s a way to do this in a more explicit way. Something like: b=a(a1=1,a2=2,a3=3).
The reason would be readability (so one would know what the variables of the struct are without having to know the right order to put them in. So ideally, b=a(a3=3,a1=1,a2=2) would also work.
Is this supported or would it take a lot of code to achieve (like making some fancy functions)?

Also, any disadvantage of using mutable structs vs regular ones?
Thanks a lot!

8 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles