ruby-core

Mailing list archive

[#65451] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...

Issue #10333 has been updated by Koichi Sasada.

9 messages 2014/10/07

[ruby-core:65432] [ruby-trunk - Feature #10318] [PATCH 0/n] Let underscore be positionally matched arg to omit binding obvious variable.

From: nobu@...
Date: 2014-10-06 06:26:40 UTC
List: ruby-core #65432
Issue #10318 has been updated by Nobuyoshi Nakada.


Why expanding tabs?

----------------------------------------
Feature #10318: [PATCH 0/n] Let underscore be positionally matched arg to o=
mit binding obvious variable.
https://bugs.ruby-lang.org/issues/10318#change-49217

* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee:=20
* Category:=20
* Target version: Next Major
----------------------------------------
I=E2=80=99m so sorry for just proposing this future without PATCH right now=
 ...

(I suppose it contains too much issues.)

After some discussions, let me implement this future.

Of course I need to obtain your consent.

Anyway, I want to let underscore be positionally matched arg and omit to bi=
nding obvious variable when it comes to proc, lambda and block .

```
# let items be a Array of String. (e.g. items =3D ['foo', 'bar', 'foobar']

# Before
items.select { |item| item.include?('foo') }

# After
items.select { _.include?('foo') }

```

Even if block has more than 2 args, I want to omit one of them.

(I know it has much pain ... just idea)

```
# let nums be a Array of Integer. (e.g. nums =3D [1, 2, 3, 4]

# Before
nums.inject { |sum, num| sum + num }

# After
nums.inject { |sum| sum + _ }
#=E2=86=91 It seems to difficult to hundle .. but looks aesthetic or unders=
tandable.
```

Let me know how do you think about it or what problem is.

thank you. gogo.


---Files--------------------------------
convert_tabs_to_spaces.patch (29.3 KB)


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

In This Thread

Prev Next