From: Joel VanderWerf Date: 2009-07-21T06:04:33+09:00 Subject: Re: getting char from string as fixnum in 1.8 and 1.9 Joel VanderWerf wrote: > brabuhr@gmail.com wrote: ... >>> cat foo.rb >> unless 0.respond_to?(:ord) >> class Integer >> def ord; self; end >> end >> end ... >> Still meets the constraint: "without adding methods to String" >> :-) > > That seems like a pretty good approach, actually, and it happens to be > what the snmp gem does (lib/ber.rb): The reason I wanted to avoid adding anything to String was that I couldn't think of a method name that would be pretty safe from conflict without being too verbose or obscure (String#get_nth_char_as_int ?). It's hard to imagine Integer#ord ever meaning anything other than this (it does in 1.8.7 and 1.9.1, as Glenn pointed out), so it seems safe to import it from future, as they say. Thanks everyone! (This will help bit-struct run in 1.9.) -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407