Issue #11660 has been updated by alanwu (Alan Wu).


Since the beginning of time (correct me if I'm wrong), the two falsy values in Ruby has been `false` and `nil`, period.
Adding another falsy value is a big change.

> the missing/undefined second arg to f3 invocation flows all the way down to f1 where it triggers default value computation
> You can't do this in ruby,

You can do it if all the methods in the chain use splat. In 2.7 `...` also works:

```ruby
def f3(foo = 500, bar)
  p [foo, bar]
end

def f2(*args)
  f3(*args)
end

def f1(*args)
  f2(*args)
end

f1(:bar) # [500, :bar]
```
https://wandbox.org/permlink/3xAq9B2wQk8odafG

Default args have been a feature for a long time, the fact there hasn't been
proposal similar to yours suggests to me that it's not a feature in high
demand.

----------------------------------------
Feature #11660: a falsy value (similar to js undefined) that facilitates forwarding of default arguments
https://bugs.ruby-lang.org/issues/11660#change-82437

* Author: bughit (bug hit)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I'll call it "missing" here.  Consider the following scenario:

```ruby
def foo(default1 = some_expression)
end

def bar(default1 = some_expression)
  foo default1
end

def foobar(default1 = some_expression)
  bar default1
end 
```

if you had "missing":

```ruby
def foo(default1 = some_expression)
end

def bar(default1 = missing)
  foo default1
end

def foobar(default1 = missing)
  bar default1
end 
```
missing passed as arg would be ignored (as if it wasn't passed at all)
and you wouldn't have to repeat the default value expression in every method

I believe that's how undefined works in js6 with respect to default args 




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>