Alan Coromano
Alan Coromano

Reputation: 26008

New style of hash notation

This one works

items = Item.where(:item_id.in => items.map(&:id))

unlike these two

items = Item.where(item_id:.in items.map(&:id))
items = Item.where(item_id.in: items.map(&:id))

Is there any way to convert the first expression of "old style Ruby hash" to the "new style Ruby hash" notation?

Upvotes: 0

Views: 271

Answers (1)

sawa
sawa

Reputation: 168071

No there isn't. The {key: value} notation for a hash is only available when the key can be written as a symbol literal.

Upvotes: 2

Related Questions