[ruby-core:95648] [Ruby master Feature#11660] a falsy value (similar to js undefined) that facilitates forwarding of default arguments

From: bughitgithub@...
Date: 2019-11-01 23:55:44 UTC
List: ruby-core #95648
Issue #11660 has been updated by bughit (bug hit).


It's conceivable that it can be done without a keyword, there are other way to refer to special values.

However what do you have against a null coalescing operator? It's needed regardless of this issue, || and ||= are inadequate because of false.

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

* 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:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next