From: mame@... Date: 2019-08-14T09:00:30+00:00 Subject: [ruby-core:94347] [Ruby master Feature#16102] `Symbol#call` Issue #16102 has been updated by mame (Yusuke Endoh). I agree that `ary1.zip(ary2, ary3)` is asymmetric and uncool, but I don't like solving the issue by adding a method of Symbol. `:zip.(*arrays)` looks too cryptic and semantically hacky to me. Rather, I like your #8970: `Array.zip(ary1, ary2, ary3)`. It is much simpler, clearer, and easier to understand. ---------------------------------------- Feature #16102: `Symbol#call` https://bugs.ruby-lang.org/issues/16102#change-80750 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Since symbols have a `to_proc` method, it is natural to expect that they would appear in a method chain like: ```ruby :some_symbol.to_proc.call(...) ``` In fact, I have use cases like this: ```ruby arrays = [["a", "b"], ["c"], ["d", "e"]] hashes = [{"a" => 1}, {"b" => 2, "c" => 3}, {"d" => 4, "e" => 5}] :product.to_proc.(*arrays) # => [["a", "c", "d"], ["a", "c", "e"], ["b", "c", "d"], ["b", "c", "e"]] :zip.to_proc.(*arrays) # => [["a", "c", "d"], ["b", nil, "e"]] :union.to_proc.(*arrays) # => ["a", "b", "c", "d", "e"] :merge.to_proc.(*hashes) # => {"a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5} ``` I request `Symbol#call` to be defined, which would implicitly call `to_proc` on the receiver and then the conventional `Proc#call` on the result. Then, I can do: ```ruby :product.(*arrays) # => [["a", "c", "d"], ["a", "c", "e"], ["b", "c", "d"], ["b", "c", "e"]] :zip.(*arrays) # => [["a", "c", "d"], ["b", nil, "e"]] :union.(*arrays) # => ["a", "b", "c", "d", "e"] :merge.(*hashes) # => {"a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5} ``` This would solve what proposals #6499, #6727, #7444, #8970, #11262 aim to do. Notice that proposals #12115 and #15301 ask for `Symbol#call`, but they ask for different things (a method that returns a proc), and are irrelevant to the current proposal. -- https://bugs.ruby-lang.org/ Unsubscribe: