#093 Ruby 2.7 New Features
Investigating new features in Ruby 2.7.0, released 2019-12-25
Notes
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
Keyword argument-related changes
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