Last active
November 1, 2020 09:33
-
-
Save ap/de85241b45fce641fbdc793bff17e009 to your computer and use it in GitHub Desktop.
Wantarray::Horrible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Wantarray::Horrible; | |
sub new { | |
my ( $class, $wantarray, $sub ) = ( shift, shift, shift ); | |
; $wantarray ? bless [ &$sub ], __PACKAGE__.'::List' | |
: defined $wantarray ? bless \( scalar &$sub ), __PACKAGE__.'::Sclr' | |
: bless \do { &$sub; my $o }, __PACKAGE__.'::Void'; | |
} | |
sub Wantarray::Horrible::List::value { @{ $_[0] } } | |
sub Wantarray::Horrible::Sclr::value { ${ $_[0] } } | |
sub Wantarray::Horrible::Void::value { () } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment