Actions
Bug #11035
closedCalling #hash method: inconsistency between dynamic and static symbols
ruby -v:
2.3dev
Description
There is an inconsistency between static symbols and dynamic symbols.
class Symbol
def hash
raise
end
end
h = {}
h[:foo] = 1 #=> no problem
h['bar'.to_sym] = 2 #=> unhandled exception
I think it should be same behavior.
My favorite is skip calling #hash for all Symbol objects.
Updated by nobu (Nobuyoshi Nakada) about 10 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r50182.
hash.c: compare symbols by identities
- hash.c (rb_any_hash): Symbols are compared by the identities
always. [ruby-core:68767] [Bug #11035]
Updated by usa (Usaku NAKAMURA) almost 10 years ago
- Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED
Updated by nagachika (Tomoyuki Chikanaga) almost 10 years ago
- Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE
Backported into ruby_2_2
branch at rr50620.
Actions
Like0
Like0Like0Like0