Forums

Defining optional parameters

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Defining optional parameters

Postby Ajrat » Thu Dec 20, 2012 3:10 am

I don't found a way to create a method can takes optional arguments.
In Cobra has this able?
Sorry for my bad English.
Ajrat
 
Posts: 8

Re: Defining optional parameters

Postby hopscc » Thu Dec 20, 2012 5:33 am

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 ... )
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand

Re: Defining optional parameters

Postby Ajrat » Thu Dec 20, 2012 5:42 am

I had in mind example like for c#:
Code: Select all
public static void ExampleMethodWithDefiningOptionalParameters(string name = "Default name")
        {
            _name = name;
        }
Sorry for my bad English.
Ajrat
 
Posts: 8

Re: Defining optional parameters

Postby hopscc » Thu Dec 20, 2012 8:36 pm

Oh - named method parameters.
No cobra doesnt support this. ( not at the moment at least :) )
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron