From: xkernigh@... Date: 2017-08-24T22:26:25+00:00 Subject: [ruby-core:82460] [Ruby trunk Feature#11105] ES6-like hash literals Issue #11105 has been updated by kernigh (George Koehler). This ES6 syntax for hash literals looks strange to me. I have never seen it before today, but I have not written JavaScript for a few years, and I am not using Ruby for web development. Two things puzzle me: 1. What is the key in `{@a}`? I want `:@a` as the key, others want `:a`. I don't expect Ruby to change `a` into `@a`. For example, `object.instance_variable_get :a` raises NameError, but `object.instance_variable_get :@a` works. 2. Should `{print}` call the method `print` if there's no local variable? That's what `{print: print}` would do. ---------------------------------------- Feature #11105: ES6-like hash literals https://bugs.ruby-lang.org/issues/11105#change-66270 * Author: shugo (Shugo Maeda) * Status: Rejected * Priority: Normal * Assignee: * Target version: ---------------------------------------- Why not support ECMAScript6-like hash literals? For example, {x, y} is equivalent to: {x: x, y: y} For convenience, the prefix of global, instance, and class variables should be removed from the key name as follows: a = 1 B = 2 $c = 3 @d = 4 @@e = 5 p({a, B, $c, @d, @@e, f: 6}) #=> {:a=>1, :B=>2, :c=>3, :d=>4, :e=>5, :f=>6} ---Files-------------------------------- 0001-support-ES6-like-hash-literals.patch (3.88 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: