Welcome, Guest. Please Login
YaBB - Yet another Bulletin Board
 
  HomeHelpSearchLogin  
 
Set default argument values in a function (Read 1122 times)
hyphyInfant
YaBB Newbies
*
Offline


Curious HyPhy user

Posts: 8
Set default argument values in a function
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.
Back to top
 
 
IP Logged
 
Sergei
YaBB Administrator
*****
Offline


Datamonkeys are forever...

Posts: 1658
UCSD
Gender: male
Re: Set default argument values in a function
Reply #1 - 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);
}



 



Sergei
Back to top
 

Associate Professor
Division of Infectious Diseases
Division of Biomedical Informatics
School of Medicine
University of California San Diego
WWW WWW  
IP Logged
 
hyphyInfant
YaBB Newbies
*
Offline


Curious HyPhy user

Posts: 8
Re: Set default argument values in a function
Reply #2 - Apr 16th, 2014 at 10:27pm
 
Hi Sergei,

   Thanks for your swift response.

hyphyInfant.
Back to top
 
 
IP Logged