E
Emmanuel Oga
Is it normal to be kicked off of irb when a Fatal error occurs ? I was
kicked of of it while testing this (kicked off != code halt with an
exception):
$ irb
irb(main):001:0> def is_prime?(n); ("1" * n) !~ /^1?$|^(11+?)\1+$/ ;
rescue NoMemoryError; puts "ouch"; end
=> nil
irb(main):002:0> is_prime?(2)
=> true
irb(main):005:0> is_prime?(100000000)
ouch
=> nil
irb(main):006:0> is_prime?(1000000000)
[FATAL] failed to allocate memory
$
p.s.: is_prime? method taken from
http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/
kicked of of it while testing this (kicked off != code halt with an
exception):
$ irb
irb(main):001:0> def is_prime?(n); ("1" * n) !~ /^1?$|^(11+?)\1+$/ ;
rescue NoMemoryError; puts "ouch"; end
=> nil
irb(main):002:0> is_prime?(2)
=> true
irb(main):005:0> is_prime?(100000000)
ouch
=> nil
irb(main):006:0> is_prime?(1000000000)
[FATAL] failed to allocate memory
$
p.s.: is_prime? method taken from
http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/