Perl5-IDEA
Perl5-IDEA copied to clipboard
Parameters are not displayed in the structure view when I set a default assignment for a parameter
Hi, when I read in the function parameters via shift and I set a default value via the || notation, the parameters are no longer displayed in the structure view. Is it possible to fix this?
sub exampleGetProductImageByID {
my $param_sCompanyID = shift;
my $param_sProductID = shift;
....
sub exampleGetProductImageByID {
my $param_sCompanyID = shift || "oode";
my $param_sProductID = shift || "335418GN";
....
regards,
Jan-Felix
Yep, stumbled on this. Feels like not very easy, but yes, doable
It happens also with the defined-or operator (‘//’)
Best regards, Emanuele
yep
defined-or operator
oh, I didn't know the operator at all. It is often more useful than the || operator.
Hi,
I would have another idea. How about if there would be an annotation (maybe @parameter) with which I could define a variable as a parameter? because in practice it will probably be really difficult to cover all cases. See for example my example.
#@parameter
my $param_refHashOrArray = shift;
#@parameter
my $param_arefKeyPath = IsArray($_[0]) ? $_[0] : [ @_ ]; ## optional
Edit: it would be very cool if you could add an option to the annotation. e.g. #@parameter(optional=1) or so? Maybe there could also be more options (e.g. type=...)
@leobm how do you see this case in a form of signature?
somemethod($param_refHashOrArray, ???);