Just another Perl shrine | |
PerlMonks |
Return a list or an iteratorby nferraz (Monk) |
on Apr 17, 2006 at 09:34 UTC ( [id://543785]=perlmeditation: print w/replies, xml ) | Need Help?? |
I don't know if this is a common idiom, but I thought it was interesting, so I'm sharing with you. This is a common way to return lists or references, depending on the calling context:
Now, since I was studying how to create iterators using closures, I tried this:
In other words, "return a list or an iterator": we can call the function like this:
And we can call it "iteractivelly":
As I said, I'm not sure if this is a common idiom (or even an useful one), but it seemed interesting so I decided to share with you. : )
Back to
Meditations
|
|