Skip to content

Instantly share code, notes, and snippets.

@marshallshen
Created October 30, 2012 16:36
Show Gist options
  • Save marshallshen/3981374 to your computer and use it in GitHub Desktop.
Save marshallshen/3981374 to your computer and use it in GitHub Desktop.
Alternative way of convert values to strings in a hash
# 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