Exercise: double numbers
Create a function that gets an array reference and multiplies each value in it by 2;
my @numbers = (2, 4, 7);
multiply_by_two(\@numbers);
print "@numbers\n"; # 4 8 14
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
Create a function that gets an array reference and multiplies each value in it by 2;
my @numbers = (2, 4, 7);
multiply_by_two(\@numbers);
print "@numbers\n"; # 4 8 14