SPVM::BlessedObject::Array - SPVM Array
The object of the SPVM::BlessedObject::Array class holds a SPVM array.
SPVM::BlessedObject::Array
# Gets an element of the array my $elem = $blessed_object_array->get(2); # Sets an element of the array $blessed_object_array->set(2 => 5); # Converts a SPVM array to a Perl array reference my $elems = $blessed_object_array->to_elems; # Converts a SPVM array to a binary my $binary = $blessed_object_array->to_bin;
my $elem = $blessed_object_array->get($index);
Returns an element of the array with the index.
$blessed_object_array->set($index, $elem);
Sets an element of the array with the index.
If the $elem can't be assigned to the element of the array, an exception is thrown.
my $elems = $blessed_object_array->to_elems;
Converts a SPVM array to a Perl array reference and returns it.
my $binary = $blessed_object_array->to_bin;
Converts a SPVM array to a binary and returns it.
This binary is unpacked by unpack function.
If the array is an object array, an excetion is thrown.
Examples:
# byte[] my @elems = unpack 'c*', $binary; # short[] my @elems = unpack 's*', $binary; # int[] my @elems = unpack 'l*', $binary; # long[] my @elems = unpack 'q*', $binary; # float[] my @elems = unpack 'f*', $binary; # double[] my @elems = unpack 'd*', $binary;
my $elems = $blessed_object_array->to_strings;
Converts a SPVM string array to a Perl array reference and returns it.
Each element calls to_string method.
my $elems = $blessed_object_array->to_bins;
Converts a SPVM string array to Perl array reference and returns it.
Each element calls to_bin method.
Overloads the following operators.
my @elems = @$array;
This is the same as the following operation.
my @elems = @{$array->to_elems};
Copyright (c) 2023 Yuki Kimoto
MIT License
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.