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

Set struct's parameters using a function whose first argument is for the struct

$
0
0

Hi, I’m trying to reuse a function to set parameters of a struct.
For example, I have a function whose the first argument should have type MyStruct:

function set_parameter(mystruct::MyStruct)
    mystruct.a = 1
end

And I want to use it to set some parameters of the following struct.

mutable struct MyStruct
    ???? = set_parameter(????)
    b::Int
end

The reason why I’m trying to do this is to reuse the function, which is that I used to do in Python.

Is there any way to resolve this?

10 posts - 6 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles