R
RichardOnRails
Hi,
The following is a toy abstract from an app I'm writing.
hash = {:Name=>"Tom"}
hash.each_key { |key|
puts "key %s (class = %s) => %s (class = %s)" %
[key.inspect, key.class, hash[key], hash[key].class]
case hash[key].class
when String; p has[key]
else; puts "hash[key].class not found"
end
}
The output is:
key :Name (class = Symbol) => Tom (class = String)
hash[key].class not found
Why isn't the "when String" statement executed?
Thanks in Advance,
Richard
P.S. I wonder if the time will come when I won't regularly stumble
over apparent anomalies when writing Ruby code.
The following is a toy abstract from an app I'm writing.
hash = {:Name=>"Tom"}
hash.each_key { |key|
puts "key %s (class = %s) => %s (class = %s)" %
[key.inspect, key.class, hash[key], hash[key].class]
case hash[key].class
when String; p has[key]
else; puts "hash[key].class not found"
end
}
The output is:
key :Name (class = Symbol) => Tom (class = String)
hash[key].class not found
Why isn't the "when String" statement executed?
Thanks in Advance,
Richard
P.S. I wonder if the time will come when I won't regularly stumble
over apparent anomalies when writing Ruby code.