Project

General

Profile

Actions

Bug #11802

closed

Hash.new and {} have different behaviour

Added by aufi (Marek Aufart) over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
[ruby-core:72032]

Description

It looks that {} is not recognized as a variable sometimes.

irb(main):001:0> p Hash.new
{}
=> {}
irb(main):002:0> p {}
=> nil

Similar in rspec test:

expect(subject.something).to eq {} # fails on not given argument for eq
expect(subject.something).to eq({}) # works

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0