Skip to content

Instantly share code, notes, and snippets.

@yagince
Created June 23, 2013 05:28
Show Gist options
  • Select an option

  • Save yagince/5843899 to your computer and use it in GitHub Desktop.

Select an option

Save yagince/5843899 to your computer and use it in GitHub Desktop.
use 5.012;
sub my_push {
my $list_ref = shift;
my $item = shift;
push @$list_ref, $item;
}
my @orig = (1,2,3);
my_push \@orig, 10;
# my_push \(1,2,3), 10; #これはできない Not an ARRAY reference たしかに、配列ではなくて、リスト、、だけど。
say "@orig";
@yagince
Copy link
Author

yagince commented Jun 23, 2013

my_push [(1,2,3)], 10;

無名配列コンストラクタという物を知った。
なるほど、やっとわかってきた。

リストと配列の違い。

@yagince
Copy link
Author

yagince commented Jun 23, 2013

my_push [1,2,3], 10;

これで良かった。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment