:s.respond_to?(:dup) && :s.dup raises

Hi all !

Symbol lies about it's ability to respond_to? to #dup:

irb(main):001:0> :s.respond_to?(:dup)
=> true
irb(main):002:0> :s.dup
TypeError: can't dup Symbol
        from (irb):2:in `dup'
        from (irb):2

Fixnum does the same thing. You might argue that the object *can*
respond to :dup, except it's simply illegal to respond to it.

Anyway, my feeling is that Symbol and Fixnum (probably Numeric) should
not respond_to?(:dup).

Thanks !

···

--
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/

François Beausoleil wrote:

Anyway, my feeling is that Symbol and Fixnum (probably Numeric) should
not respond_to?(:dup).

Here's a 76-post thread on this very subject, from about six, seven
weeks ago.

http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/239426?239426-239938

···

--
Posted via http://www.ruby-forum.com/\.