Skip to content

Instantly share code, notes, and snippets.

@thomas-holmes
Created January 10, 2014 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomas-holmes/cb589b10239757d399c8 to your computer and use it in GitHub Desktop.
Save thomas-holmes/cb589b10239757d399c8 to your computer and use it in GitHub Desktop.
t = Time.now
case t
when defined?(String) && String then puts 'string'
when defined?(DateTime) && DateTime then puts 'datetime'
when defined?(Time) && Time then puts 'time'
else puts 'wtf'
end
#=> thomas@e3 ~/Code/test $ ruby test.rb
#=> time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment