From: Jason Roelofs Date: 2006-12-19T23:16:40+09:00 Subject: Re: Division hangs irb ------=_Part_5117_3953528.1166537790575 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 12/19/06, Jason Roelofs wrote: > > On 12/19/06, Ashley Moran wrote: > > > > > On 19 Dec 2006, at 14:06, Vincent Fourmond wrote: > > > > > Irb takes the latter as the beginning of a regular expression for > > > the > > > first argument of to_f: > > > > > >>> (DateTime.now - Date.new (2006,9,15)).to_f /30 > > > / > > > ArgumentError: wrong number of arguments (1 for 0) > > > from (irb):10:in `to_f' > > > from (irb):10 > > > from /usr/lib/ruby/1.8/rational.rb:520 > > > > > > Cheers, > > > > > > Vince > > > > > > Thanks Vince, cleared that up > > > > I wondered why that didn't work but "10 /5" did > > > > Ashley > > > > to_f vs / > > I'll add the appriopriate params to show you what the parser sees: > > (DateTime.now - Date.new(2006,9,15)).to_f ( /30 ) # /30 is taken in as a > single param because of lack of space and because you're calling to_f > > 10 /5 => 10./(5) # In this case, / IS the method call, as 10 is not a > method, so the parser figures this out correctly. > > Either way, just put spaces there. It looks better and is easier to read. > > Jason > One more thing to help you understand: (DateTime.now - Date.new(2006,9,15)).to_f() /30 # this will work ------=_Part_5117_3953528.1166537790575--