From: pjb@... (Pascal J. Bourguignon) Date: 2009-03-04T18:48:40+09:00 Subject: Re: fixnum problem plz help Brian Candler writes: > Pascal J. Bourguignon wrote: >> In more strongly typed programming languages such as Common Lisp, >> you'd get an error: >> >> C/USER[929]> (* "2" 365) >> >> *** - *: "2" is not a number > > This is nothing to do with "strongly typed". Ruby's concept of the > difference between a string and an integer is just as strict as LISP's. > > Rather, Ruby provides semantics to the '*' operator/function for strings > which LISP doesn't. > > You can get exactly the behaviour you desire by _removing_ some Ruby > functionality. > > irb(main):001:0> String.class_eval { undef_method(:*) } > => String > irb(main):002:0> "2" * 365 > NoMethodError: undefined method `*' for "2":String > from (irb):2 > from :0 Right, it is too much overloading, not weak typing. Sorry for the confusion. -- __Pascal Bourguignon__