⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (516 Bytes)
Bug #4437
ยป getc_bug.rb
Sample program that shows the error. -
bobjalex (Bob Alexander)
, 02/24/2011 12:08 PM
# Create a file with the single character 'x', then read it back into var x.
open
(
'x'
,
'w'
)
{
|
f
|
f
.
write
(
'x'
)}
x
=
open
(
'x'
)
{
|
f
|
f
.
getc
}
# Create a Hash with 'x' as a key.
h
=
{
'x'
=>
'xx'
}
# Retrieve the value, to show that the hash (of course) works with ordinary
# characters.
p
'h["x"] =>'
,
h
[
"x"
]
p
'h[?x] =>'
,
h
[
?x
]
# Retrieve the value using the 'x' obtained using getc, showing that the
# hash match fails for the same character retrieved from a file.
puts
p
'x =>'
,
x
p
'h[x] =>'
,
h
[
x
]
(1-1/1)
Loading...