TiL: Double Splat Nil in Ruby

How Ruby can do what you don’t expect Ruby is a very clever language. It will take the code you’ve written and do it’s best to make sure it runs. Take for example the following method call: method_one('Hello', param_two: ' world') That looks simple enough as it takes two arguments, one positional and one keyword. Now, lets take a look at what the method is actually doing: def method_one(param_one, param_two) p param_one, param_two end Interesting. At first glance it might appear that this method would print Hello world, but there is a subtle difference between how the method has been defined and how it is called. Let’s see what it actually outputs: ...

June 9, 2025 · 2 min · 384 words · George Bell