I would like to format a string containing float variables, including them with a fixed number of decimal places, and I would like to do this using this formatting syntax:
amount = Math::PI puts "Current amount: #{amount}"
and I would like to receive Current amount: 3.14 .
I know I can do it with
amount = Math::PI puts "Current amount %.2f" % [amount]
but I ask if this can be done with #{} .
ruby
marcotama Sep 12 2018-12-12T00: 00Z
source share