Created
October 30, 2012 16:36
-
-
Save marshallshen/3981374 to your computer and use it in GitHub Desktop.
Alternative way of convert values to strings in a hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Old way | |
hash = { | |
"starts_at" => Date.today.to_s, | |
"ends_at" => (Date.today + 2.days).to_s | |
} | |
# Alternative way | |
hash = { | |
"starts_at" => Date.today, | |
"ends_at" => Date.today + 2.days | |
} | |
hash.update(hash){|k,v| v.to_s} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment