From: Stefano Crocco Date: 2010-09-09T21:43:14+09:00 Subject: Re: .gcd method in ruby 1.8.7 On Thursday 09 September 2010, hazal Ates wrote: > |> You're right. In ruby 1.8.7 the gcd method is defined in rational.rb, > |> which is > |> part of the standard library. To make your program work you simply have > |> to > |> require it. The reason it worked for me is that this file is > |> automatically > |> required on my system when starting irb. > |> > |> I hope this helps > |> > |> Stefano > | > |thanks but now another problem : > | > |when i wrote : Rational ( 26,65 ) it gives syntax error :( > | > |>ruby ratio.rb > | > |ratio.rb:1: syntax error, unexpected ',', expecting ')' > |Rational (6 , 10) > | ^ > | > |>Exit code: 1 > | > |normally it must give : (2/5) This is strange. It works for me. An attempt I'd do is to remove the space between Rational and the parentheses. Ruby behaviour when you put a space before a parentheses can be unintuitive (if calling ruby with the -w switch, it should give a warning about it). Stefano