Comments on: Ruby String Formatting http://www.blackbytes.info/2012/01/ruby-string-formatting/ Ruby Programming Tutorials Mon, 01 Aug 2016 12:39:13 +0000 hourly 1 http://wordpress.org/?v=4.3.6 By: Jesus Castello http://www.blackbytes.info/2012/01/ruby-string-formatting/#comment-444 Thu, 21 Jan 2016 02:55:04 +0000 http://blackbytes.wordpress.com/?p=7#comment-444 You code looks ok, but since 20 is already 2 digits long you won’t get any padding. Try with "%04d" % number.

]]>
By: Jordan Christley http://www.blackbytes.info/2012/01/ruby-string-formatting/#comment-443 Thu, 21 Jan 2016 02:42:26 +0000 http://blackbytes.wordpress.com/?p=7#comment-443 I am trying to use the 0 padding method in a practice on Cloud9, and although the server is recognizing and accepting it as valid ruby code, I am not getting the desired output. Here is my code:

number = 20
puts "%02d" % [number]

]]>