Page 1 of 1

Defining optional parameters

PostPosted: Thu Dec 20, 2012 3:10 am
by Ajrat
I don't found a way to create a method can takes optional arguments.
In Cobra has this able?

Re: Defining optional parameters

PostPosted: Thu Dec 20, 2012 5:33 am
by hopscc
Yes it does.

Have a look at the methods wiki page under 'Method paramlist' and <ParamDesc>
Theres a small example in the Examples section following

I think theres also a longer example in the
Howto section of the Doc

How to Declare a variable number of args

( If thats not clear enough query back in this topic and I'll go through it here and try and fixup the wiki page so it is ... )

Re: Defining optional parameters

PostPosted: Thu Dec 20, 2012 5:42 am
by Ajrat
I had in mind example like for c#:
Code: Select all
public static void ExampleMethodWithDefiningOptionalParameters(string name = "Default name")
        {
            _name = name;
        }

Re: Defining optional parameters

PostPosted: Thu Dec 20, 2012 8:36 pm
by hopscc
Oh - named method parameters.
No cobra doesnt support this. ( not at the moment at least :) )