Name
SPVM::BlessedObject::Array - Array based blessed object
DESCRIPTION
SPVM::BlessedObject::Array is array based blessed object.
This object contains SPVM array object.
Usage
# Get the value of an array element
my $value = $sp_array->get(2);
# Set the value of an array element
$sp_array->set(2 => 5);
# Convert SPVM array to Perl array reference
my $elems = $sp_array->to_elems;
# Convert SPVM array to Perl binary data
my $binary = $sp_array->to_bin;
Methods
get
my $value = $sp_array->get(2);
Get the value of an array element.
set
$sp_array->set(2 => 5);
Set the value of an array element
to_elems
my $elems = $sp_array->to_elems;
Convert SPVM array to Perl array reference.
to_bin
my $binary = $sp_array->to_bin;
Convert SPVM array to binary data.
Binary data is unpacked by unpack
function.
An exmaple when array is int array:
my @nums = unpack 'l*', $binary;
to_strings
my $elems = $sp_array->to_strings;
Convert SPVM string
array to Perl string array reference by calling to_string
method of each element.
to_bins
my $elems = $sp_array->to_bins;
Convert SPVM string
array to Perl binary array reference by calling to_bin
method of each element.
Operators
SPVM::BlessedObject::Array overloads the following operators.
array dereference
Array dereference get the elements of the array.
# Get elements
my @elements = @$array;
This is the same as the following.
my @elements = @{$array->to_elems};