'Least surprise', Mats, eh?

ethan on 2003-08-15T06:53:12

While drilling my String::Ruby methods to behave as their Ruby counterparts, I noticed this little oddity in Ruby which seems to violate the least-surprise-rule:

print "- 377".oct ==> -255 print "- 377".oct ==> 0

So how many whitespaces may I add before ruby starts vomitting? Seven actually. Now I wonder whether hex() allows up to 15.....*tests*...no, just four! Funny.

The downside of that: I can't blindly use ruby's output as test-cases. I planned on writing a couple of ruby scripts that I have automatically converted into test scripts. Or at least I have to hand-edit them afterwards and take out those test-failures that are caused by Ruby bugs (I guess the above is one).