Ruby 1.8: NoMethodError: undefined method `ord' for "":String

Missing String#ord in Ruby 1.8? Here's a simple monkey-patch that will add it to Ruby.

unless "".respond_to?(:ord)
class String
def ord
self[0].ord
end
end
end

http://gist.github.com/251465

0 comments:

Post a Comment