Assign method call to hash value?
piemas25 at gmail.com
Tue Jan 29 12:44:25 GMT 2013
> I'm still not clear why assigning $r->method as a hash value doesn't invoke a scalar
> context, which is what I wanted rather than the array context option for
> $r->method. In the end I found:
1. "assigning $r->method" does not invoke any context.
In this case, the context is "we are inside a hash".
2. A hash is a list.
It's just a list which knows that its elements are "coupled" 2 by 2.
As a consequence, inside a hash you are in list context.
3. In this list context, any method that is context-sensitive will
return a list.
If you want to force your method to return a scalar anyway,
you have to use the scalar() function.
Is that clear?
If not, which part is not clear?
More information about the london.pm