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

Ruby.next

 Ruby.next

Slide-deck from my presentation at Grill.rb 2018 in Wroclaw, Poland.

Bozhidar Batsov

August 12, 2018
Tweet

More Decks by Bozhidar Batsov

Other Decks in Programming

Transcript

  1. •keyword arguments •%i •UTF-8 is now the default source file

    encoding •Refinements (experimental feature)
  2. •Top-level constant look-up is removed •rescue/else/ensure are allowed inside do/end

    blocks •refinements take place in string interpolations

  3. •endless ranges (1..) •begin/else/end is now a syntax error (it

    used to be a warning) •some core lib methods now take optional keyword arguments (e.g. system(), Integer(), Float()) •a first stab at MJIT •built-in AST module
  4. pry(main)> Ripper.sexp('alias :some :test') => [:program, [[:alias, [:symbol_literal, [:symbol, [:@ident,

    "some", [1, 7]]]], [:symbol_literal, [:symbol, [:@ident, "test", [1, 13]]]]]]]
  5. each(:method_add_arg, sexp) do |s| next if s[1][0] != :call receiver

    = s[1][1][1] method_name = s[1][3][1] if receiver && receiver[1] == 'Array' && method_name == 'new' && s[2] == [:arg_paren, nil] offences.delete(Offence.new(:convention, receiver[2].lineno, ERROR_MESSAGE)) add_offence(:convention, receiver[2].lineno, ERROR_MESSAGE) end end
  6. –Zach Tellman There has been a consistent migratory pattern from

    Ruby to node.js to Go, Rust, and Elixir. At first, each community is defined by its potential. But as that potential is realized, the community begins to be defined by its compromises. That change is felt most keenly by the people who were there first, who remember what it was like when anything seemed possible. They feel fenced in and so they move on, in search of their golden city…”
  7. PHP

  8. The Future of Java and the JDK Who’s in charge?

    https://www.youtube.com/watch?v=HpbchS5kmio
  9. class Foo # <b>DEPRECATED:</b> Please use <tt>useful</tt> instead. def useless

    warn "[DEPRECATION] `useless` is deprecated. Please use `useful` instead." useful end def useful # ... end end
  10. class MyFile extend Gem::Deprecate def no_more close end deprecate :no_more,

    :close, 2015, 5 def close # new logic here end end
  11. class Struct def deconstruct; [self] + values; end end A

    = Struct.new(:a, :b) case A[0, 1] in (A, 1, 1) :not_match in A(x, 1) # Syntactic sugar of above p x #=> 0 end
  12. class Struct def deconstruct; [self] + values; end end A

    = Struct.new(:a, :b) match A[0, 1] in (A, 1, 1) :not_match in A(x, 1) # Syntactic sugar of above p x #=> 0 end
  13. class SomeClass =begin This is a top comment. Or is

    it? =end def some_method end end
  14. class SomeClass =begin This is a top comment. Or is

    it? =end def some_method end end
  15. pry(main)> A = 5 => 5 pry(main)> A = 6

    (pry):39: warning: already initialized constant A (pry):38: warning: previous definition of A was here => 6 pry(main)> Class = 3 (pry):40: warning: already initialized constant Class => 3 pry(main)> Class => 3
  16. class Parent @@class_var = 'parent' def self.print_class_var puts @@class_var end

    end class Child < Parent @@class_var = 'child' end Parent.print_class_var # => will print "child"
  17. [1] pry(main)> defined? 10 => "expression" [2] pry(main)> defined? Test

    => nil [3] pry(main)> defined? TrueClass => "constant"
  18. $:

  19. $;

  20. $*