⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (382 Bytes)
Bug #19448
ยป bug.rb
Also contains a workaround -
bobanj (Boban Jovanoski)
, 02/17/2023 03:39 PM
# frozen_string_literal: true
require
'set'
# Bug
h
=
Hash
.
new
(
Set
.
new
)
h
[
:a
]
<<
1
h
[
:b
]
<<
2
puts
"keys:
#{
h
.
keys
}
"
puts
"h[:a]:
#{
h
[
:a
]
}
"
puts
"h[:b]:
#{
h
[
:b
]
}
"
puts
'Expecting to see :a and :b in list of keys'
# Workaround
puts
'With workaround'
h
=
Hash
.
new
{
|
hash
,
key
|
hash
[
key
]
=
Set
.
new
}
h
[
:a
]
<<
1
h
[
:b
]
<<
2
puts
"keys:
#{
h
.
keys
}
"
puts
'Keys are displayed correctly'
(1-1/1)
Loading...