use Carp qw(croak);
-our $VERSION = '0.02';
+our $VERSION = '0.03';
with 'Moose::Autobox::Ref',
'Moose::Autobox::Indexed';
[ CORE::map { [ $_, $hash->{$_} ] } CORE::keys %$hash ];
}
+sub slice {
+ my ($hash, $keys) = @_;
+ return [ @{$hash}{@$keys} ];
+};
+
sub print { CORE::print %{$_[0]} }
sub say { CORE::print %{$_[0]}, "\n" }
=item B<kv>
+=item B<slice>
+
=back
=over 4
requires 'keys';
requires 'values';
requires 'kv';
+requires 'slice';
1;
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
-=cut
\ No newline at end of file
+=cut
use strict;
use warnings;
-use Test::More tests => 62;
+use Test::More tests => 63;
BEGIN {
use_ok('Moose::Autobox');
$h->perl,
'... the value is correctly dumped with perl()' );
+is_deeply( { one => 1, two => 2, three => 3 }->slice([qw/three one/]),
+ [ qw/3 1/ ],
+ '... hash slices ok' );