Fork me on GitHub

Project Notes

Ruby 2.7 New Features

Investigating new features in Ruby 2.7.0, released 2019-12-25


Install with RVM

After updating rvm, “ruby-2.7.0” is available for installation. NB: .ruby-version and .ruby-gemset in this folder are setup to isolate an Ruby 2.7 environment.

$ rvm get stable
$ rvm install "ruby-2.7.0"

Syntax Changes

test_syntax_changes.rb tests a few new syntax changes:

  • comments allowed between dotted call chains
  • rescue with mutilple assignment
  • beginless ranges
$ ./test_syntax_changes.rb
4 runs, 10 assertions, 0 failures, 0 errors, 0 skips

Enumerables and Collections

test_enumerables.rb tests a few Enumerables and Collections new features:

  • filter_map
  • tally
$ ./test_enumerables.rb
3 runs, 3 assertions, 0 failures, 0 errors, 0 skips

Numbered Block Parameters

test_numbered_parameters.rb tests the numbered block parameter new feature:

In block without explicitly specified parameters, variables _1 through _9 can be used to reference parameters.

$ ./test_numbered_parameters.rb
4 runs, 4 assertions, 0 failures, 0 errors, 0 skips

test_keyword_args.rb tests Keyword argument-related changes

  • Argument forwarding
$ ./test_keyword_args.rb
2 runs, 6 assertions, 0 failures, 0 errors, 0 skips

Pattern matching

test_pattern_matching.rb tests the new and experimental pattern matching feature

$ ./test_pattern_matching.rb
2 runs, 6 assertions, 0 failures, 0 errors, 0 skips

Credits and References

About LCK#106 ruby
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.