in reply to Re^2: set context for method's return values
in thread set context for method's return values
I thought it's akin to 0+ which enforces scalar context and numeric casting (also in other languages like JS).
But it's basically a No-OP which separates a function from the parens, such that the parens are not interpreted as part of the function call.
It has sufficiently low precedence and doesn't meddle with context:
DB<9> say ("a".."c")[1] syntax error at (eval 18)[c:/Strawberry/perl/lib/perl5db.pl:738] line +2, near ")[" DB<10> say (("a".."c")[1]) # how it works b DB<11> say +("a".."c")[1] # avoid extra parens b DB<12> say +("a".."c")[1..2] # LIST uneffected bc DB<13>
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: set context for method's return values (unary plus)
by rsFalse (Chaplain) on Jan 29, 2022 at 11:47 UTC | |
|
Re^4: set context for method's return values (unary plus)
by demoralizer (Beadle) on Feb 01, 2022 at 07:47 UTC |