Created
August 14, 2014 14:34
-
-
Save hakobe/55231183fdb0fab2d6ae to your computer and use it in GitHub Desktop.
"Perl5.20のKey/Value Hash Slice" + "リストをスカラコンテキストで評価するとリストの最後の値になる" が組み合わさった様子
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use utf8; | |
use v5.20.0; | |
my $h = { | |
hoge => 'hoo', | |
fuga => 'foo', | |
}; | |
my $v1 = %{$h}{hoge}; | |
warn $v1; # => hoo | |
my $v2 = %{$h}{'hoge', 'fuga'}; | |
warn $v2; # => foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HashのリファレンスになってるところをHashに変えると以下の様な警告が出る。(逆に上のような例だと警告でない)