Ruby 2.7クイズ / Ruby 2.7 Quiz

Ruby 2.7クイズ / Ruby 2.7 Quiz

社内勉強会の資料

B433dfef4ca935a7320df9fc96871aeb?s=128

Hiromichi NOMATA

May 26, 2020
Tweet

Transcript

  1. Ruby 2.7ΫΠζ @hiromichinomata

  2. ύλʔϯϚον case {a: 0, b: 1, c: 2} in {a:

    0, i: 1} puts 1 in {a: 0, b: tmp} puts 2 in {a: 0, b: 1, c: tmp} puts 3 in {a: 0, b: 1, c: 2} puts 4 end ग़ྗ͞ΕΔจࣈ͸?
  3. ύλʔϯϚον case {a: 0, b: 1, c: 2} in {a:

    0, i: 1} puts 1 in {a: 0, b: tmp} puts 2 in {a: 0, b: 1, c: tmp} puts 3 in {a: 0, b: 1, c: 2} puts 4 end ౴͑: 2
  4. irbʹ௥Ճ͞Εͨͷ͸? 1. ෳ਺ߦฤू 2. readline͕ෆཁʹ 3. ΫϥεɺϞδϡʔϧɺϝιουͷϦϑΝϨϯεΛͦͷ৔ Ͱ֬ೝͰ͖ΔΑ͏ʹ 4. inspect݁Ռʹ৭͕ͭ͘Α͏ʹ

  5. irbʹ௥Ճ͞Εͨͷ͸? 1. ෳ਺ߦฤू 2. readline͕ෆཁʹ 3. ΫϥεɺϞδϡʔϧɺϝιουͷϦϑΝϨϯεΛͦͷ৔ Ͱ֬ೝͰ͖ΔΑ͏ʹ 4. inspect݁Ռʹ৭͕ͭ͘Α͏ʹ

    ౴͑: શ෦
  6. ΩʔϫʔυҾ਺ͱͯ͠ڐ༰͞Ε Δͷ͸? 1. def foo(h, **kw); end; foo(key: 42) 2.

    def foo(h, key: 42); end; foo(key: 42) 3. def foo(**kw); end; foo({key: 42}) 4. def foo(h, key: 42); end; foo({key: 42})
  7. ΩʔϫʔυҾ਺ͱͯ͠ڐ༰͞Ε Δͷ͸? 1. def foo(h, **kw); end; foo(key: 42) 2.

    def foo(h, key: 42); end; foo(key: 42) 3. def foo(**kw); end; foo({key: 42}) 4. def foo(h, key: 42); end; foo({key: 42}) =>
  8. Ruby 2.7ΛίϯύΠϧ͢Δͷʹඞ ཁͳͷ͸? 1. C90 2. C99 3. C11 4.

    C17
  9. Ruby 2.7ΛίϯύΠϧ͢Δͷʹඞ ཁͳͷ͸? 1. C90 2. C99 3. C11 4.

    C17
  10. ิ଍: C99৽ػೳྫ * ม਺એݴ͕ϒϩοΫͷઌ಄͚ͩͰͳ͘࢖͍͍ͨ ͱ͖ʹએݴՄೳʹ * forจͷΧ΢ϯλม਺Λࣄલʹએݴෆཁʹ

  11. ूܭϝιου ["a", "b", "c", "b"].xxx #=> {"a"=>1, "b"=>2, "c"=>1} 1.

    count_map 2. sum_map 3. pally 4. tally
  12. ूܭϝιου ["a", "b", "c", "b"].xxx #=> {"a"=>1, "b"=>2, "c"=>1} 1.

    count_map 2. sum_map 3. pally 4. tally
  13. ิ଍ • ӳޠͰtally͸צఆɺूܭ͢Δͱ͍͏ҙຯ

  14. ൪߸ࢦఆύϥϝλʔ [1,4,3].map{puts xxx} # => 1 4 3 1. _0

    2. _1 3. $0 4. $1
  15. ൪߸ࢦఆύϥϝλʔ 1. _0 2. _1 3. $0 4. $1 [1,4,3].map{puts

    xxx} # => 1 4 3
  16. ࢀߟ • https://www.ruby-lang.org/ja/news/ 2019/12/25/ruby-2-7-0-released/