Ruby – Get ASCII value

October 30, 2009

Example 1:

puts ?r  #=> 114

puts ?a #=> 97

Example 2:

output=”raveendran”

puts output[0]  #=>114 ‘value of r’

puts output[1] #=> 97  ‘value of a’

Example 3:

output=”raveendran”
output.each_byte do |a|
puts a
end

>ruby ascii_from_ruby.rb
114
97
118
101
101
110
100
114
97
110
>Exit code: 0


 

2 Responses to “Ruby – Get ASCII value”

  1. vaddi Says:

    good work ravee.. keep posting

    • raveendran Says:

      Thanks Vaddi.


Leave a Reply