This page is READ-ONLY. It is generated from the old site.
All timestamps are relative to 2013 (when this page is generated).
If you are looking for TeX support, please go to VietTUG.org

Ruby1.9 Time type inference

how bad it is
Added by icy 17 days ago  »  Votes: 1/1

The correct way should be s.to_i - t.to_i > foobar. And we don't need to know the type of s or t.

 1 $ irb
 2 1.9.3-p194 :001 > s = Time.now
 3  => 2013-03-11 16:17:02 +0700 
 4 1.9.3-p194 :002 > t = Time.now
 5  => 2013-03-11 16:17:03 +0700 
 6 1.9.3-p194 :003 > t - s > 10
 7  => false 
 8 1.9.3-p194 :004 > t - 10 > 1
 9 ArgumentError: comparison of Time with 1 failed
10         from (irb):4:in `>'
11         from (irb):4
12         from /home/rvm/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
13 1.9.3-p194 :005 >
14 

Comments