Forum: Ruby Prime.include?(1) hangs Ruby scripts and irb

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D7165b0fa24ed038a6ace50c22ac5a7a?d=identicon&s=25 Frisco Del Rosario (Guest)
on 2009-01-15 08:40
(Received via mailing list)
Ruby version 1.8.6
Mac OS 10.5.2

I would like a Ruby script to do something if a result is a prime
number, or do something else if the result is not prime. But Ruby is
hanging on instance_of_Prime.includes?(some prime number). For example,
in irb:

$ irb
>> require 'mathn'
=> true
>> foo=Prime.new
=> #<Prime:0x32bab8 @primes=[], @seed=1, @counts=[]>
>> puts foo.include?(2)
true
=> nil
>> puts foo.include?(1)

Expected:
false

Got:
Nothing, and programs won't exit.
D0338c0de4cb3c5c17300396159933d1?d=identicon&s=25 Axel Etzold (Guest)
on 2009-01-15 10:20
(Received via mailing list)
-------- Original-Nachricht --------
> Datum: Thu, 15 Jan 2009 16:39:03 +0900
> Von: Frisco Del Rosario <friscodelrosario@nospamsbcglobal.net>
> An: ruby-talk@ruby-lang.org
> Betreff: Prime.include?(1) hangs Ruby scripts and irb

> => true
> Got:
> Nothing, and programs won't exit.
>

Hi --

I can confirm that behaviour on Ruby 1.8.7 and Ubuntu 8.04.
I think you should file a bug with the authors of mathn.

Best regards,

Axel
This topic is locked and can not be replied to.