Posted 9 months ago. Visible to the public. Repeats.

Ruby: required keyword arguments in the pre-2.1 era

Starting with Ruby 2.0 you can define methods with keyword arguments.

In 2.1+ required keyword arguments can be defined by using a colon without default value:

Copy
def match(value, ignore:) ... end

To accomplish something similar in ruby 1.8, use:

Copy
def match(value, options = {}) ignore = options.fetch(:ignore) ... end
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Daniel Straßner
Last edit:
8 months ago
by Besprechungs-PC
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Daniel Straßner to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more