From: James Coglan Date: 2009-08-05T20:44:21+09:00 Subject: Re: Bizarre Range behavior --001636c5a45fedfa440470638530 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/8/5 Brian Candler > Yukihiro Matsumoto wrote: > > What if I sprinkle more magic to the language and change String#upto > > to generate numerical sequences when all characters in edges are > > digits, so that > > > > irb> ("2".."19").to_a > > => ["2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", > > "14", "15", "16", "17", "18", "19"] > > irb> ("2"..."20").to_a > > => ["2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", > > "14", "15", "16", "17", "18", "19", "20"] > > > > Any opinion? > > -1 for added complexity with little benefit I'm also against this. I prefer explicit type conversions here: changing behaviour because a string happens to look like a number will likely cause more problems than it solves. In fact this kind of thing shows up in JavaScript and it usually masks bugs where the developer has failed to properly handle user input. If this change were to go ahead, I'd also argue for changing String#+ to recognise numbers, which might also mean changing Numeric#+ for symmetry. -- James Coglan http://jcoglan.com --001636c5a45fedfa440470638530--