From: Eric Hodel Date: 2006-03-24T20:18:39+09:00 Subject: Re: How is Symbol#to_int useful? (should it exist?) On Mar 24, 2006, at 1:33 AM, Phil Tomson wrote: > I had a situation in a DSL like so: > > str = '0'*n > > Where n in one context could be a Symbol. If n happened to be a > Symbol, I > wanted to get an error message. However, I found that if n is a > symbol you > could get a very long string of 0's because there is a > Symbol#to_int method > which returns a unique integer for each Symbol object (actually, it > calls > Symbol#to_i). And so I don't get the error message I want to get > because the > symbol gets converted to an Integer automatically. So what's the > usefulness of > the Symbol#to_int method? I'm just undefining it like so: > > class Symbol > undef_method :to_int > end > > ....that works for my purposes, but I wonder why there is a > Symbol#to_int method in the library. Why not just require that > Symbol#to_i be > called explicitly if that's what you want? Symbols used to be just numbers without names attached. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com