I want to print it in this format: ex.
1 -> 000001 15 -> 000015
How can i do this? thank
sprintf "%06d", 1 #=> "000001" sprintf "%06d", 15 #=> "000015"
or more briefly
"%06d" % 1 #=> "000001" "%06d" % 15 #=> "000015"
"#{1}".rjust(6,'0') # => 000001 "#{15}".rjust(6,'0') # => 000015
You can use Kernel # sprintf or line formatting ( %) as follows:
%
>> "%06d" % 1 => "000001" >> "%06d" % 15 => "000015"
Source: https://habr.com/ru/post/1750635/More articles:bash: flushing stdin (standard input) - bashRendering partial to a table row with form_tag is getting crazy! - htmlHow to write INT64 in CString - c ++Escaping from C #, a little puzzled - c #Column of time sqlite3 - sqlasp.net mvc - How to quickly and efficiently create fake test objects - unit-testingForcing mouse movement along a specific axis in WPF - wpfanimation to move: position change visualization - jqueryUsing WCF RIA services where the data source is not a classic (relational) database - .netDebugging only with .exe - debuggingAll Articles