The "puts" command can be used with sprintf syntax using the percent (%) sign as follows:
puts "ABC %2.2f" % 3.567
=> "ABC 3.57"
puts "ABC %2.2f DEF %5s" % [3.567, "abcd"]
=> "ABC 3.57 DEF abcd"
Subscribe to:
Post Comments (Atom)
Politics, Computers, Ruby on Rails, and Miscellaneous.
No comments:
Post a Comment