Need help to understand the difference between #dup and #clone while working singleton methods

Look the below code with Object#clone:

foo = Object.new def foo.bar   "hi" end baz = foo.clone foo.bar # => "hi" baz.bar # => "hi"

Now with Object#dup

foo = Object.new def foo.bar   "hi" end baz = foo.dup foo.bar # => "hi" baz.bar # `<main>': undefined method `bar' for #<Object:0x989b378> (NoMethodError)

Why the below part didn't work.

I’d think, the difference in following example shows easier, where is the difference in you case, too

foo = [1,2] bar= foo.dup

foo<< 3

puts bar.inspect

foo= [ [1,2] ]

bar = foo.dup

foo[0] << 3

puts bar.inspect