Skip to content

Instantly share code, notes, and snippets.

@iffyuva
Created September 4, 2014 13:20
Show Gist options
  • Save iffyuva/37cc5224a0506add9534 to your computer and use it in GitHub Desktop.
Save iffyuva/37cc5224a0506add9534 to your computer and use it in GitHub Desktop.
time comparison fun in ruby
:013 > nil <=> Time.current
=> nil
:014 > Time.current <=> nil
NoMethodError: undefined method `to_datetime' for nil:NilClass
from /Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/core_ext/date_time/calculations.rb:161:in `<=>'
from /Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/core_ext/time/calculations.rb:286:in `compare_with_coercion'
from /Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/time_with_zone.rb:214:in `<=>'
from (irb):14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment