Ruby Version Changes

By Jesus Castello

On this page I compiled some of the most important Ruby version changes starting with Ruby 2.0. This includes both features of the language itself & new methods that can help you write better Ruby code.

If you'd like to know what version of Ruby you have installed you can run this command:

ruby -v

Inside a Ruby program you can use the RUBY_VERSION constant.

Hope you find this useful!

Ruby 2.5

New Features

  • Reversed stack trace
  • About 5-10% performance improvement
  • You can now use rescue / else / ensure with a do / end block

Methods

  • Kernel#yield_self
  • Hash#transform_keys / Hash#transform_keys!
  • Hash#slice
  • String#delete_prefix / String#delete_suffix
  • Enumerable#any?, all?, none?, and one? accept a pattern argument
  • Struct.new can create classes that accept keyword arguments

Ruby 2.4

New Features

  • Fixnum + Bignum merge into Integer
  • Better Thread error reporting
  • Refinements now work with Kernel#send & Symbol#to_proc

Methods

  • Dir.empty?
  • File.empty?
  • Regexp#match?
  • Enumerable#sum
  • Integer#digits
  • Hash#compact / Hash#compact!
  • Hash#transform_values / Hash#transform_values!
  • Kernel#clone now takes an optional keyword argument (freeze).

Ruby 2.3

New Features

  • Frozen strings pragma
  • Safe navigator operator (&.)
  • Squiggly heredoc (<<~)
  • 'Did you mean?' gem included by default

Methods

  • Hash#dig
  • Array#dig
  • File.mkfifo
  • Hash#fetch_values
  • Enumerable#chunk_while
Ruby 2.2

New Features

  • Symbol GC
  • Incremental GC
  • Support Unicode 7.0

Methods

  • Method#curry
  • Kernel#itself
  • Enumerable#slice_after
  • Enumerable#slice_when
  • Float#next_float, Float#prev_float (#9834)

Share this page if you like it!

Ruby 2.1

New Features

  • Required Keyword Arguments
  • Generational GC
  • New GC environment variables
  • Refinements

Methods

  • String#scrub and String#scrub!
  • Binding#local_variable_get(symbol)
  • Binding#local_variable_set(symbol, obj)
  • Binding#local_variable_defined?(symbol)
Ruby 2.0

New Features

  • Lazy enumerators
  • Keyword Arguments
  • UTF-8 as default encoding
  • Refinements (experimental)
  • New regular expression engine
  • `%i` and `%I` for symbol list creation (similar to `%w` and `%W`)

Methods

  • Kernel#__dir__
  • Array#bsearch
  • Module#prepend
  • Module.prepended
  • Module.prepend_features
  • Return an Array instead of an Enumerator:
    • String#chars
    • String#bytes
    • ​String#lines
    • String#codepoints

Click the button below to share this page if you found it useful :)