Setting a default variable?

Hey guys

Basically I have loop which looks like this:

function readVtkVariables(filename::String,reset::Bool)
        k::Array{String} = []
        #Open the specific file
        fd::IOStream = open(filename, read=true)
        for i in instances(Cat)
            #Read until the specific enum string has been found. Ie. Mk => "Mk " etc.
            if reset == true
            readuntil(fd, searchString[i])
            k = push!(k,string(i))
        return k

What I would like to do is to set the “reset” input as false always, unless otherwise stated. So basically I want the user to be able to write, this which would be the same thing:


I know I could do multiple dispatch, but I think that shouldn’t be necessary for this short code.

Kind regards

function readVtkVariables(filename::String,reset::Bool = false)
1 Like

Thanks! Much better than Matlab’s nargin in my opinion, so I am a happy man :slight_smile:

1 Like

Continued future happiness can be ensured by reading the manual, eg



Haha, you are of course right. Often times I try doing a quick google search and seeing if anything comes up - then it is nice for us not so tech-savvy people with a forum, with a lot of helpful heads :slight_smile: