Skip to content

Instantly share code, notes, and snippets.

@DGaffney
Created February 24, 2011 22:52
Show Gist options
  • Select an option

  • Save DGaffney/843067 to your computer and use it in GitHub Desktop.

Select an option

Save DGaffney/843067 to your computer and use it in GitHub Desktop.
bling = {"blah"=>0.0038, "bloo"=>0.01}
bling.each_pair do |name, value|
val = sprintf( "%.02f" , value).to_s.to_f
bling[name] = val if val!=0
end
puts bling.inspect
=> {"blah"=>0.0038, "bloo"=>0.01} #does this? WTF?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment