eval.in

Paste #495653

Ruby — MRI 2.2, pasted 3 years ago (json)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
p 42.method(:dup).owner

[
  1,
  2.0,
  3i,
  4r,
  2 ** 64,
  Numeric.new,
  :foo
].each { |o| o.dup rescue p $! }

Program Output

Kernel
#<TypeError: can't dup Fixnum>
#<TypeError: allocator undefined for Float>
#<TypeError: can't copy Complex>
#<TypeError: can't copy Rational>
#<TypeError: allocator undefined for Bignum>
#<TypeError: can't copy Numeric>
#<TypeError: can't dup Symbol>

OK (0.064 sec real, 0.069 sec wall, 9 MB, 23 syscalls)

Fork