HyPhy message board
http://www.hyphy.org/cgi-bin/hyphy_forums/YaBB.pl
Methodology Questions >> How to >> Set default argument values in a function
http://www.hyphy.org/cgi-bin/hyphy_forums/YaBB.pl?num=1397586707

Message started by hyphyInfant on Apr 15th, 2014 at 11:31am

Title: Set default argument values in a function
Post by hyphyInfant on Apr 15th, 2014 at 11:31am
Hello,

     I have a function I would like to specify default values for some of its arguments so that I will not have to supply these arguments whenever I need to use the function, unless I prefer better value(s) to the default. I have no idea how this can be done on HyPhy. I will appreciate if anyone could assist.

Thanks in advance,
hyphyInfant.

Title: Re: Set default argument values in a function
Post by Sergei on Apr 16th, 2014 at 4:18pm
Hi there,

There is no mechanism for doing so in HyPhy (there will be in version 3 currently under development).

A kludgy workaround is to provide wrapper functions which prefill the arguments by default:

[code]

function full (a,b,c) {
...
}

function shorthand (a) {
     return full (a, 0, 1);
}



[/code]

Sergei

Title: Re: Set default argument values in a function
Post by hyphyInfant on Apr 16th, 2014 at 10:27pm
Hi Sergei,

   Thanks for your swift response.

hyphyInfant.

HyPhy message board » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2024. All Rights Reserved.