Method: String#ord

Defined in:
lib/extra/string.rb

#ordObject

For anyone who still misses PHP or Python’s ord() functions… which I’ve learned to not need in Ruby, here it is.

Example: 'a'.ord #=> 97

Returns: Fixnum or nil



61
62
63
# File 'lib/extra/string.rb', line 61

def ord
  self[0]
end