Ruby hash equivalent of JavaScript's object initializer ES6 shorthand

前端 未结 5 474
心在旅途
心在旅途 2021-01-07 23:02

In JavaScript ES6 we can create objects where variable names become keys like this:

> let a = \'aaa\'
\'aaa\'

> let b = \'bbb\'
\'bbb\'

> { a, b }         


        
5条回答
  •  借酒劲吻你
    2021-01-07 23:19

    It has been proposed in Ruby #15236 - Add support for hash shorthand and has unfortunately been rejected for the moment.

提交回复
热议问题