Upgrade to Pro — share decks privately, control downloads, hide ads and more …

postfix dereference 徹底攻略 / effective postfix dereference

B5582ce2d9959dfcff0384a07003e188?s=47 mackee
March 30, 2018

postfix dereference 徹底攻略 / effective postfix dereference

Gotanda.pm #16

B5582ce2d9959dfcff0384a07003e188?s=128

mackee

March 30, 2018
Tweet

Transcript

  1. postfix dereference పఈ߈ུ @mackee_w a.k.a macopy Gotanda.pm #16

  2. ୭ˠ • twitter: @mackee_w • GitHub: mackee • kuiperbelt/kuiperbelt :

    WebSocketศར܅ • ࠷ۙPerl Hackers Hubʹςετͱ͔ͷهࣄΛॻ ͍ͨ
  3. postfix dereference ͬͯԿ

  4. postfix dereference $hashref->%* $arrayref->@*

  5. postfix dereference $hashref->%* $arrayref->@*

  6. postfix dereference $hashref->%* $arrayref->@*

  7. ղઆ

  8. postfix dereference %{$hashref} || $hashref->%*

  9. postfix dereference @{$arrayref} || $arrayref->@*

  10. postfix ɹ= έπʹͭ͘ dereference ɹ= σϦϑΝϨϯε ུ: postderef

  11. ֗ͷ੠   ಡΊͳ͍ ͜Ε͸ศརʂ

  12. ϝϦο τ

  13. ϝϦοτ • ߦͬͯʙฦͬͯͬͯͳΒͳ͍ %{$aaa->{bbb}} $aaa->{bbb}->%* 1 2 3 4 5

    6 7 1 2 3 4 5 6
  14. σϝϦοτ

  15. ……ͳΜͰ ه߸૿΍ͪ͠Όͬͨͷʁ

  16. ͓٬༷ɺ ه߸͸૿΍͓ͯ͠Γ·ͤΜɺ ه߸ͷ૊Έ߹ΘͤΛ૿΍ͨ͠ ͚ͩͳͷͰ͢……

  17. ૊Έ߹Θͤ……

  18. ୭͕ * ͚ͩͩͱݴͬͨ

  19. hash slicing my $hashref = { k1 => "v1", k2

    => "v2", k3 => "v3" }; # ී௨ͷσϦϑΝϨϯε͔ΒͷϋογϡεϥΠε my ($v1, $v3) = @{$hashref}{qw/k1 k3/}; # postderefͰϋογϡεϥΠε my ($v1, $v3) = $hashref->@{qw/k1 k3/};
  20. ࣮࣭JSͷobject destructuringͰ͸ʁʁʁ ※ӈลʹ΋ॻ͔ͳ͍ͱ͍͚ͳ͍ͷͰҧ͍·͢ https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

  21. ·ͱΊ • ʢ໨ͱख͕֮͑Ε͹ʣศར • *͚ͩͰ͸ͳ͍ɻΉ͠ΖͦΕҎ֎͕ศར • v5.24͔Βexperimental֎Εͨɻ࢖͑· ͢ʂʂʂʂ • ࠓճͷίʔυ͸શ෦use

    v5.24.0;ͯ͠·͢
  22. http://perldoc.jp/docs/perl/5.24.0/perl5240delta.pod

  23. postderef_qqͬͯͳʹ

  24. postderef_qq my $hashref = { k1 => “v1", k2 =>

    "v2", k3 => "v3" }; print "[$hashref->@{qw/k1 k3/}]\n"; # => [v1 v3]
  25. ͳΔ΄Ͳͳʁ

  26. csvΈ͍ͨʹग़ͨ͠Γ my @columns = qw/c1 c2 c3/; my $data =

    [ { c1 => "aa", c2 => "bb", c3 => "cc" }, { c1 => "dd", c2 => "ee", c3 => "ff" }, { c1 => "gg", c2 => "hh", c3 => "ii" }, ]; $" = ","; print "@columns\n"; print "$_->@{@columns}\n" for @$data;
  27. csvΈ͍ͨʹग़ͨ͠Γ $ perl postderef.pl c1,c2,c3 aa,bb,cc dd,ee,ff gg,hh,ii

  28. Ͳ͏Αʁʁʁʁ

  29. ײ૝ • ϫϯϥΠφʔͱ͔Ͱศརͦ͏ • jqͷ୅ΘΓʹ࢖͏ͱ͔ • ͱ͸͍͑·ͣv5.24ʹ্͛Δͱ͜Ζ͔Β……