Modern Ruby tour

Contents
Endless methods
Numbered _1 params
Pattern matching recap
Ruby 3.x in production

Endless methods

Short methods fit on one line with the endless form. Write the name, the params, an equals sign, and the single expression body.

Reach for the classic def with end as soon as the logic needs branches, loops, or more than one line.

def hi(name) = "hi #{name}" puts hi("Ada")

Numbered _1 params

Tiny blocks can skip naming params entirely. The _1 placeholder stands for the first block argument automatically.

Numbered params shine in one line iterators and fade fast in longer blocks, where a real name reads better.

["ada", "bob"].each { puts _1 }

Pattern matching recap

Case with in branches matches shape, not just value. An array pattern binds each element to a fresh variable in one move.

This recap stays with the simple array form from the Ruby pattern lesson, which already covers most everyday uses.

case [1, 2] in [a, b] puts a + b end

Ruby 3.x in production

Modern syntax pays off only on a modern runtime. Pin the Ruby version per project and upgrade through test suites with real coverage.

New library methods like except remove whole manual steps, so prefer them over hand rolled filtering helpers.

user = { name: "Ada", password: "secret" } puts user.except(:password).inspect

Next: Hero roadmap: the whole course on one page

Article author: Arthur Isaev

Related articles
Ruby
Ruby course: zero to hero in 50 lessons
What is Ruby and where it runs
Install Ruby and check the version
irb: the interactive shell
Your first Ruby script
Variables
Numbers
Strings
Symbols
Truthiness: only false and nil
Conditions
Loops
Arrays
Hashes
Ranges
Methods
Blocks, procs, lambdas
String tools
Files and IO
Exceptions
Modules and mixins
Classes and objects
Inheritance
Enumerables
Duck typing and core idioms
Gems and Bundler
Testing with Minitest
Debugging
Encodings
Time and date
JSON and YAML
HTTP clients
Sockets
REST APIs
puts, print and p
Metaprogramming
Enumerators
Pattern matching
Arguments: splats and kwargs
Rake tasks
Environment and CLI
Logging
CSV
ERB templates
WEBrick server
Rails in one lesson
Capstone: todo CLI
Capstone: JSON API
Performance
Modern Ruby tour
Hero roadmap: the whole course on one page
Install Ruby on Windows 11
Install Ruby on Ubuntu
Install Ruby on Rocky Linux
Install Ruby on macOS
Install Ruby on FreeBSD
Ruby in Docker
Threads and fibers

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: