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

Ruby 3.0 Redux (Pivorak 4.0)

Ruby 3.0 Redux (Pivorak 4.0)

Avatar for Bozhidar Batsov

Bozhidar Batsov

October 18, 2019
Tweet

More Decks by Bozhidar Batsov

Other Decks in Programming

Transcript

  1. То є Львів, мій колєґа, про нього різне кажуть: Приезжим

    из востока Криївку тут покажуть. То є Львів, моє місто, не з простого тіста, Ліплений роками – друзями й ворогами. То є Львів старенький, мудрий, сивий дядько, Кожному залишить кавалочок на згадку. То є Львів "Бонжорно!", Неаполь і Ліворно, По-галицьки говорять, наші в них погоду роблять.
  2. То є Львів, шановні, вбирайте шлюбні сподні, Краватку, маринарку і

    "вйо!" по Стрийськім парку. То є Львів чудовий, вуйко ґонуровий, Я тішуся, шо з вами ходжу цими вулицями. То є Львів старенький, мудрий, сивий дядько, Кожному залишить кавалочок на згадку. То є Львів "Бонжорно!", Неаполь і Ліворно, По-галицьки говорять, наші в них погоду роблять. То є Львів, то Львів...
  3. noun 1. a precious stone consisting of corundum in colour

    varieties varying from deep crimson or purple to pale rose. 2. a programming language optimised for programmer happiness
  4. 3

  5. number 1. equivalent to the sum of one and two;

    one more than two; 3 2. A mystical version rarely achieved by most software projects.
  6. adjective 1. brought back, revived Emacs era redux 2. (usually

    postpositive) (esp of an artistic work) presented in a new way Apocalypse Now Redux
  7. person = JSON.parse('{...}', symbolize_names: true) if person[:name] == ‘Alice’ children

    = person[:children] if children.length == 1 && children[0][:name] == ‘Bob’ p children[0][:age] end end
  8. > $; = " " warning: non-nil $; will be

    deprecate => " " > "hello world!".split warning: $; is set to non-nil value => ["hello", "world!"] > $, = " " warning: non-nil $, will be deprecated => " " > ["hello", "world!"].join warning: non-nil $, will be deprecated => "hello world!"
  9. irb • New reline backend (portable replacement for readline) •

    Completion • Multi-line editing • Syntax-highlighting • Integration with RDoc
  10. class Person @name: String @contacts: Array<Email | Phone> def initialize:

    (name: String) -> any def name: -> String def contacts: -> Array<Email | Phone> def guess_country: -> (String | nil) end
  11. Open Questions • Is Steep becoming part of the Standard

    Library? • How is Sorbet going to make use of its type annotations? • Typing applications
  12. $ exe/type-profiler test.rb test.rb:6: [error] undefined method: Integer#boo test.rb:7: [error]

    failed to resolve overload: Integer#+ Object#foo :: (Integer) -> String
  13. # The following calls pass keyword arguments foo(..., key: val)

    foo(..., **hsh) foo(..., key: val, **hsh)
  14. def a_method(k: 1) puts "k: #{k}" end a_method({k: 1}) (irb):4:

    warning: The last argument is used as the keyword parameter (irb):1: warning: for `a_method' defined here => k: 1
  15. # To avoid the warning # and make it Ruby

    3 compatible, # use the double splat operator a_method(**{k: 1}) => k: 1
  16. • Ruby 2.7 will be the final release in the

    2.x series • Ruby 3.0 is scheduled to land in 2020 • Ruby 2.7 will serve as a preview for many of the key features in Ruby 3.0 • Static typing and Guilds are the biggest changes coming to Ruby 3.0 • Keyword argument overhaul is going to be a breaking change • The migration path from Ruby 2.x to 3.x should be very smooth
  17. Community Contributions • Rake • Bundler • Documentation & Tutorials

    • A ton of amazing libraries • Rails • …