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

Ruby 2.5 What's New

Urabe Shyouhei
November 29, 2017

Ruby 2.5 What's New

Urabe Shyouhei

November 29, 2017
Tweet

More Decks by Urabe Shyouhei

Other Decks in Technology

Transcript

  1. Urabe, Shyouhei Ruby 2.5
 What’s New

  2. ·ͣ͸֓ܗ͔Β

  3. EJ⒎TUBUT ˠ 1585 files changed, 147854 insertions(+), 72571 deletions(-) ˠ

    1549 files changed, 120363 insertions(+), 70385 deletions(-) ˠ 2933 files changed, 103658 insertions(+), 62082 deletions(-) ˠ 2263 files changed, 82556 insertions(+), 289978 deletions(-) ˠUSVOL 7061 files changed, 360060 insertions(+), 34025 deletions(-)
  4. None
  5. None
  6. bundler w ͍·ͷͱ͜Ζ͓ͦΒ͘࠷ޙͷඪ४ఴ෇ϥΠϒϥϦ w ͔Β͸ɺઃఆෆཁͰ͍͖ͳΓGemfileΛ ͋Ε ͹ ಡΉΑ͏ʹͳΔ

  7. ଞϥΠϒϥϦ • Rubyspec • RDoc 6 (ripper integration) • ERb#result_with_hash

    • SecureRandom.alphanumeric • Binding#irb • etc.
  8. ERb#result_with_hash erb = ERb.new("<%= foo %>") erb.result_with_hash(foo: "1") # =>

    "1"
  9. SecureRandom.alphanumeric SecureRandom.alphanumeric(32) # => "Xr3GCd3y2wkUgEF9lSh5pD2s5NDpeHSM"

  10. Binding#irb def foo while true do raise unless rand <

    0.5 end rescue binding.irb # <= end
  11. ίΞΫϥε • String#delete_prefix / String#delete_suffix • Array#append / Array#prepend •

    Dir#children / Dir#each_child • Hash#transform_keys • Kernel#yield_self
  12. String#delete_prefix "log.fluentd.message {...".delete_prefix("log.") # => "fluentd.message {..."

  13. Array#append %w'dolor sit amet'.prepend(%w'lorem ipsum') # => [["lorem", "ipsum"], "dolor",

    "sit", "amet"] %w'dolor sit amet'.prepend('lorem', 'ipsum') # => ["lorem", "ipsum", "dolor", "sit", "amet"]
  14. Hash#transform_keys {foo: 'bar'}.transform_keys(&:to_s) # => {"foo"=>"bar"}

  15. Kernel#yield_self {foo: 'bar'}.yield_self {|i| JSON.dump(i) } # => "{\"foo\":\"bar\"}"

  16. จ๏ͱ͔ • do … rescue … end • Toplevel constant

    lookup removal • Reverse backtrace order
  17. do … rescue … end 128.times do |i| raise unless

    rand < 0.5 rescue RuntimeError puts $! end
  18. Reverse backtrace zsh % ruby -e 'def foo; bar; end'

    -e 'def bar; raise; end' -e 'foo' Traceback (most recent call last): 2: from -e:3:in `<main>' 1: from -e:1:in `foo' -e:2:in `bar': unhandled exception [1] 34131 exit 1 ruby -e ‘…’ zsh % ruby -e 'def foo; bar; end' -e 'def bar; raise; end' -e 'foo' 2>&1 | cat -e:2:in `bar': unhandled exception from -e:1:in `foo' from -e:3:in `<main>' [1] 34291 exit 1 ruby -e ‘…’ 2>&1 | 34292 done cat