From: SZMURLO MAURICE Date: 2000-12-21T23:45:29+09:00 Subject: [ruby-talk:7869] RE: Comparsion Problem? This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C06B5C.100B4070 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit ruby -e '"abc".each_byte {|b| p b }' 97 98 99 -> each_byte returns the ascii code... maurice # # I met a problem when I tried to write some Ruby code to learn # Ruby. The # following code just can't work as expected, # # "Hello".each_byte { |c| # if c == "o" # print "oh, i got an o!", "\n" # end # } # # Seems in Ruby, in the comparsion c and "o" is always false. # How can I make # the above code right? Thanks a lot. # # Jiangyi Liu ------_=_NextPart_001_01C06B5C.100B4070 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 7bit RE: [ruby-talk:7867] Comparsion Problem?

ruby -e '"abc".each_byte {|b| p b }'
97
98
99

-> each_byte returns the ascii code...

maurice


#
# I met a problem when I tried to write some Ruby code to learn
# Ruby. The
# following code just can't work as expected,
#
# "Hello".each_byte { |c|
#     if c == "o"
#         print "oh, i got an o!", "\n"
#     end
# }
#
# Seems in Ruby, in the comparsion c and "o" is always false.
# How can I make
# the above code right? Thanks a lot.
#
# Jiangyi Liu

------_=_NextPart_001_01C06B5C.100B4070--